您好我正在尝试在实体选择查询中调用存储过程。但我得到了错误。首先我检查外面的程序。
var img = dc.get_User_Image(1).FirstOrDefault();
var Task = from tbl_Task tsk in dc.tbl_Task
join tmp in dc.tbl_TaskAssignment
on tsk.TaskID equals tmp.TaskID into jointable
from tmp in jointable.DefaultIfEmpty()
join ct in dc.tbl_User on tmp.AssignTo equals ct.UserID
where tsk.IsDeleted == false && tsk.TaskID == IntTaskID &&
tmp.IsDeleted == false
select new
{
TaskID = tsk.TaskID,
TaskDesc = tsk.Remarks,
TaskTitle = tsk.TaskTitle,
TaskEmpName = tmp.tbl_User.tbl_Contact.FirstName_EN,
TaskEmpID = tmp.AssignTo,
profileImage = "",
Priority = tsk.Priority,
TaskCompletedPercentage = tmp.CompletedPercentage
};
没有错误。得到了结果。但将代码更改为:
var Task = from tbl_Task tsk in dc.tbl_Task
join tmp in dc.tbl_TaskAssignment on tsk.TaskID equals tmp.TaskID into jointable
from tmp in jointable.DefaultIfEmpty()
join ct in dc.tbl_User on tmp.AssignTo equals ct.UserID
where tsk.IsDeleted == false && tsk.TaskID == IntTaskID &&
tmp.IsDeleted == false
select new
{
TaskID = tsk.TaskID,
TaskDesc = tsk.Remarks,
TaskTitle = tsk.TaskTitle,
TaskEmpName = tmp.tbl_User.tbl_Contact.FirstName_EN,
TaskEmpID = tmp.AssignTo,
profileImage = dc.get_User_Image(tmp.AssignTo).FirstOrDefault(),
Priority = tsk.Priority,
TaskCompletedPercentage = tmp.CompletedPercentage
};
出错了
LINQ to Entities 无法识别方法 'System.Data.Objects.ObjectResult
1[System.String] get_User_Image(System.Nullable
1[System.Int64])' 方法,并且此方法无法转换为存储表达式。
“ dc.get_User_Image ” 接受“用户 ID” (Int) 并返回图像路径 (String)。在第一个代码中,我单独检查功能。它工作正常。在选择 Query iam 中调用 this->“profileImage = dc.get_User_Image(tmp.AssignTo).FirstOrDefault()”。它抛出了错误
我不明白为什么?请帮忙。