在它正常工作之前,我使用了相同的查询。然后我决定使用编译查询。所以我不得不对代码做一些改动。
现在,当我尝试执行代码时,我收到错误消息“不支持用于查询运算符'Where'的重载。我从“approvalHelper.GetWhereClauseForApprovalSimpleSearch();”生成的 where 子句 已经过测试并且工作正常。仅对编译后的查询部分不起作用,如我的代码所示
代码 :
// Complied Query Class
public static class CompliedQuery
{
public static Func<GDataContext, Expression<Func<View_ApprovalSimple, bool>>, IQueryable<View_ApprovalSimple>> getApprovalSimple =
CompiledQuery.Compile<GDataContext, Expression<Func<View_ApprovalSimple, bool>>, IQueryable<View_ApprovalSimple>>(
(db, whereclause) => (from results in db.View_ApprovalSimples.AsExpandable().Where(whereclause)
select results));
}
// this is what is passed into the where clause; Body = {(vas.siteId = 1)}
//the Calling code
public static List<View_ApprovalSimple> GetApprovalSimple(ApprovalsSearchHelperClass _approvalHelper)
{
Expression<Func<View_ApprovalSimple, bool>> whrClause = approvalHelper.GetWhereClauseForApprovalSimpleSearch();
//whrclause; Body = {(vas.siteId = 1)}
try
{
using (GDataContext db = new GDataContext())
{
if (whrClause != null)
{
var varResults = CompliedQuery.getApprovalSimple(db, whrClause);
return varResults.ToList();
}
}
}
catch (Exception ex)
{
// code to handle error
}
finally
{
}
return null;
}
知道我可能需要实施哪些新变化吗?
提前致谢。