不能包含虚拟导航属性
本文关键字:属性 导航 虚拟 包含 不能 | 更新日期: 2023-09-27 18:14:43
在我的模型(自动生成)中,我可以看到:
public partial class Order
{
public System.Guid OrderId { get; set; }
...
public System.Guid ProductId { get; set; }
public virtual Product Product { get; set; }
}
但是,当我尝试将产品包含到返回的集合中时(因为稍后我将需要它的一些值),在智能感知之后没有提供任何内容。
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
类提供的参数。