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 somebody assist me in resolving my problem? I'm use the code below:

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

.....

I'm using the following in my code.

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

I'm receiving the exception by doing this. [System.NotSupportedException] —- "LINQ to Entities does not support the LINQ expression node type 'Invoke'."

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

Popular Answer

The AsExpandable() function created by Joe Albahari and included in LINQKIT may be used to remedy this issue. He is the same person behindPredicateBuilder thing you're utilizing, I see.

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

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

You may download the LINQKIT DLL from here or install it using here's NuGet package.

Your issue will be resolved since it did for me.

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