Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Can';不包括虚拟导航属性_C#_Linq_Include - Fatal编程技术网

C# Can';不包括虚拟导航属性

C# Can';不包括虚拟导航属性,c#,linq,include,C#,Linq,Include,在我的模型(自动生成)中,我可以看到: public partial class Order { public System.Guid OrderId { get; set; } ... public System.Guid ProductId { get; set; } public virtual Product Product { get; set; } } 但是,当我尝试将产品包含到返回的集合中时(因为稍后我将需要它的一些值),intellisense之后没有提供任何内

在我的模型(自动生成)中,我可以看到:

public partial class Order
{
  public System.Guid OrderId { get; set; }
  ...
  public System.Guid ProductId { get; set; }
  public virtual Product Product { get; set; }
}
但是,当我尝试将产品包含到返回的集合中时(因为稍后我将需要它的一些值),intellisense之后没有提供任何内容

using (ModelContext context = new ModelContext())
  return context.Orders
    .Include(order=>order.???)
    .Where(order => order.Condition)
    .ToList();

我重新生成模型并重新运行T4脚本。其他实体的包含按预期工作。看不出我可能做错了什么。

我怀疑你忘了添加

using System.Data.Entity;

因此,您不能使用
Include
重载,将表达式作为
System.Data.Entity.QueryableExtensions
类提供的参数。

哦,但我有它,就在那里。然后我重构了文件,将两个类拆分为各自独立的文件。而愚蠢的驴屎再竖琴没有把东西带到新的档案里!对细节很有眼光,伙计+1.