我正在编写一个逻辑,用于使用Entity Framework存储过程插入记录,该过程将返回一个TeamId的int参数。我已经为商店程序创建了函数import。请参阅下面的屏幕截图
我不知道如何返回int参数。请参阅以下代码
DataAccess图层
public int InsertTeam(string countryCode, string teamName, string TeamDescription, string createdBy, char isActive)
{
using (var mcrContext = new MCREntities())
{
return (from team in mcrContext.InsertTeam(countryCode, teamName, TeamDescription, createdBy, true)
select
{
}).ToList();
}
答案 0 :(得分:0)
您从该程序中获得的是ObjectResult<T>
。在你的情况下,只需:
public int InsertTeam(string countryCode, string teamName, string TeamDescription, string createdBy, char isActive)
{
using (var mcrContext = new MCREntities())
{
var result = mcrContext.InsertTeam(countryCode, teamName, TeamDescription, createdBy, true);
return result.Single().Value;
}
}