我试过这个
var Result = from a in db.ViewEntity // view
let b = db.sp_Get_log(a.id) // parametrized stored procedure returns rowset
select new LogFields
{
UniqueID = a.ID,
WorkFlow_Status = a.Document_Status,
Creator = a.Creator,
Duration = a.Duration,
Approver = b.LastOrDefault().Action_User // this
};
但是我收到了这个错误,请帮助。
LINQ to Entities无法识别方法System.Data.Objects.ObjectResult1 [db.Agent.sp_Get_log_Fields] sp_Get_log(System.String)'方法,并且此方法无法转换为存储表达式。
答案 0 :(得分:1)
首先在内存中获取结果然后以这种方式调用存储过程:
var ResultList = db.ViewEntity.ToList();
var Result = from a in ResultList
let b = db.sp_Get_log(a.id) // parametrized store procedure returns rowset
select new LogFields
{
UniqueID = a.ID,
WorkFlow_Status = a.Document_Status,
Creator = a.Creator,
Duration = a.Duration,
Approver = b.LastOrDefault().Action_User // this
};