我有以下代码,我试图通过它使用 LINQ 创建 CompiledQuery。
public static Func<DataContext, int, object>
GetTeamMembersByTeamId = CompiledQuery.Compile<MazikReviewEntities, int, object>(
(context, teamId) => from tp in context.TeamPlayers
join t in context.Teams on tp.TeamId equals t.ID
join emp in context.Employees on tp.EmployeeId equals emp.ID
where tp.TeamId == teamId && emp.IsActive == true
orderby emp.JoiningDate
select new ProjTeamMemberDetails
{
EmployeeName = emp.FirstName + " " + emp.LastName,
Email = emp.Email,
Designation = context.Designations.FirstOrDefault(s => s.ID == emp.DesignationId).Name,
NIC = emp.NIC,
JoiningDate = emp.JoiningDate,
EmployeeID = emp.ID
});
}
在 CompiledQuery.Compile 行中,我的数据上下文出现错误,其中指出,
“类型‘MazikGlobalReviewModel.MazikReviewEntities’不能用作泛型类型或方法‘System.Data.Linq.CompiledQuery.Compile(System.Linq.Expressions.Expression>)’中的类型参数‘TArg0’。没有隐式引用从 'MazikGlobalReviewModel.MazikReviewEntities' 到 'System.Data.Linq.DataContext' 的转换。”
这是什么错误以及如何解决?