【发布时间】:2014-12-12 18:09:36
【问题描述】:
谁能帮我解决我的问题。我正在使用下面给出的代码:
public IEnumerable<InvoiceHeader> Getdata(Expression<Func<InvoiceHeader, bool>> predicate)
{
return AccountsContext.InvoiceHeaders.Include("Company").Include("Currency")
.Include("BusinessPartnerRoleList").Include("DocumentType")
.Where(predicate);
}
.....
在我的代码中我使用如下
Expression<Func<InvoiceHeader, bool>> predicate = PredicateBuilder.True<InvoiceHeader>();
predicate = predicate.And(o => o.CompanyId == oInvoiceHeader.CompanyId);
List<InvoiceHeader> lstInvheader=Getdata(predicate).ToList();
通过这样做,我得到了异常。 [System.NotSupportedException] --- {“LINQ to Entities 不支持 LINQ 表达式节点类型‘Invoke’。”}
【问题讨论】:
-
你提到了一个例外。我想你忘了添加它。
-
如果我没记错的话,这是由于您可能从互联网上获取的 PredicateBuilder 的工作方式。试试这个版本:github.com/jbevain/mono.linq.expressions/blob/master/…
标签: c# linq entity-framework expression predicate