The LINQ expression node type 'Invoke' is not supported in the entity framework's LINQ to Entities.

c# entity-framework expression linq predicate

Question

can anyone help me out in solving my issue. I am using the code given below:

public IEnumerable<InvoiceHeader> Getdata(Expression<Func<InvoiceHeader, bool>> predicate)
{
    return AccountsContext.InvoiceHeaders.Include("Company").Include("Currency")
        .Include("BusinessPartnerRoleList").Include("DocumentType")
        .Where(predicate);
}

.....

In my code I am using as below

Expression<Func<InvoiceHeader, bool>> predicate = PredicateBuilder.True<InvoiceHeader>();
predicate = predicate.And(o => o.CompanyId == oInvoiceHeader.CompanyId);
List<InvoiceHeader> lstInvheader=Getdata(predicate).ToList();

By doing this I am getting the exception . [System.NotSupportedException] --- {"The LINQ expression node type 'Invoke' is not supported in LINQ to Entities."}

1
23
7/4/2012 4:00:18 AM

Popular Answer

This problem can be solved using the AsExpandable() method present in LINQKIT by Joe Albahari. He's the same creator of PredicateBuilder that I see you're using.

If querying with Entity Framework, change the last line to this:

return objectContext.Products.AsExpandable().Where(predicate);

You can grab LINQKIT DLL here or install it through a NuGet package here.

It'll certainly solve your problem because it has solved mine.

49
7/3/2012 3:11:48 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow