2015-09-20 71 views
2

工作,我有2类:“包括” 扩展方法不LinqKit

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;} 
} 

正常查询:

return _context.Remunerations.Include("Employee") 

完美的作品

但是,当我使用阿尔巴哈利的LinqKit和给出如下查询:

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

它不会给出任何错误。

但在结果中不包含Employee数据。

回答

0

这是一个known issue他们正在努力。当前development source有一个扩展方法,该方法在ExpandableQuery(由AsExpandable()返回)上执行Include,并将其委托回原始的IQueryable

你之所以没有得到一个例外是Include是一个扩展方法上IQueryable<T>,并且ExpandableQuery还实现IQueryable。但它没有执行Include(),所以Include()运行,但它什么都不做。