Satyajit
Satyajit

Reputation: 2071

"Include" extension method does not work with LinqKit

I have 2 classes:

public class Employee
{
    public int Id {get;set;}
    public string Name {get;set;}
}

public class Remuneration
{
    public int Id {get;set;}
    public Employee Employee {get;set;}
    public int Amount {get;set;}
}

The normal query:

return _context.Remunerations.Include("Employee")

works perfect

But when I am using Albahari's LinqKit and giving the query as below:

return _context.Remunerations.AsExpandable().Include("Employee")

It does not give any error there.

But does not include the Employee data in the result.

Upvotes: 4

Views: 964

Answers (1)

Gert Arnold
Gert Arnold

Reputation: 109109

This is a known issue and they're working on it. The current development source has an extension method that executes Include on an ExpandableQuery (returned by AsExpandable()) and delegates it back to the original IQueryable.

The reason why you don't get an exception is that Include is an extension method on IQueryable<T>, and ExpandableQuery also implements IQueryable. But it doesn't have an implementation of Include(), so Include() runs, but it does nothing.

Upvotes: 2

Related Questions