bất kỳ ai cũng có thể giúp tôi giải quyết vấn đề của mình. Tôi đang sử dụng mã đưa ra dưới đây:Loại nút biểu thức LINQ 'Gọi' không được hỗ trợ trong LINQ to Entities trong khung thực thể
public IEnumerable<InvoiceHeader> Getdata(Expression<Func<InvoiceHeader, bool>> predicate)
{
return AccountsContext.InvoiceHeaders.Include("Company").Include("Currency")
.Include("BusinessPartnerRoleList").Include("DocumentType")
.Where(predicate);
}
.....
Trong mã của tôi Tôi đang sử dụng như sau
Expression<Func<InvoiceHeader, bool>> predicate = PredicateBuilder.True<InvoiceHeader>();
predicate = predicate.And(o => o.CompanyId == oInvoiceHeader.CompanyId);
List<InvoiceHeader> lstInvheader=Getdata(predicate).ToList();
Bằng cách này tôi nhận được ngoại lệ. [System.NotSupportedException] --- {"Loại nút biểu thức LINQ 'Gọi' không được hỗ trợ trong LINQ to Entities."}
Bạn đề cập đến một ngoại lệ. Tôi nghĩ bạn quên thêm nó. – THelper
Nếu tôi nhớ chính xác, điều này là do làm thế nào PredicateBuilder bạn có thể lấy từ các công trình internet. Hãy thử với phiên bản này: https://github.com/jbevain/mono.linq.expressions/blob/master/Mono.Linq.Expressions/PredicateBuilder.cs –