C# Include语句在实体框架中不起作用

C# Include语句在实体框架中不起作用,c#,database,linq,entity-framework,C#,Database,Linq,Entity Framework,这是我的密码 _DbSet.Include(x => x.Dine_In_Orders) .Include(x => x.Order_Details) .Include(x => x.Dine_In_Orders) .Include(x => x.Order_Details.Select(y => y.Product))

这是我的密码

_DbSet.Include(x => x.Dine_In_Orders)
                    .Include(x => x.Order_Details)
                    .Include(x => x.Dine_In_Orders)
                    .Include(x => x.Order_Details.Select(y => y.Product))
                    .Include(x => x.Order_Details.Select(y => y.Product.Kitchen_Products))
                    .Include(x => x.Order_Details.Select(y => y.Product.Kitchen_Products.Side_Order))
                    .Include(x => x.Order_Details.Select(z => z.Product
                        .Kitchen_Products.Side_Order.Where(n => n.Id == z.SO_Id)));
它抛出异常

"The Include path expression must refer to a navigation property defined on the type. Use dotted paths for reference navigation properties and the Select operator for collection navigation properties.Parameter name: path"

我尽我所能,但没有成功。。如果我删除最后一个include路径,它可以完美地工作,但不会给出我想要的结果。请给出一些建议,

使用
Include(“PathPart1.PathPart2”)
-您不能有条件地包含afaik,但可以在之后过滤您的结果-因此您可以说
dbset.Include(“x”).Include(“y”)。其中(x=>x.y.value==2)
(免责声明:这些可能都不是有效的代码!)我相信你不能在include中使用条件,那么我该怎么做才能使它正常工作…?@Hammad只需删除上次include中的
Where
条件即可。在你的问题中加上条件你能解释一下你想做什么吗?