4

我有 2 节课:

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")

完美运行

但是当我使用 Albahari 的 LinqKit 并给出如下查询时:

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

它在那里没有给出任何错误。

但结果中不包括 Employee 数据

4

1 回答 1

2

这是一个已知问题,他们正在解决这个问题。当前的开发源有一个扩展方法,该方法IncludeExpandableQuery(返回者AsExpandable())上执行并将其委托回原始IQueryable.

你没有得到异常的原因是它Include是一个扩展方法IQueryable<T>,并且ExpandableQuery还实现了IQueryable. 但它没有Include(), 所以Include()运行的实现,但它什么也不做。

于 2015-09-20T20:10:36.667 回答