【发布时间】:2014-12-11 18:27:05
【问题描述】:
我是使用 asp .net 和 LINQ 查询的新手。我编写了以下查询,但出现错误。
Include path expression must refer to a navigation property defined on the type
在上述问题中存在相同的错误,但他们根本没有解释为什么会发生这种情况。我相信这是因为我在下面的第三行中包含了内联 .First() 方法,但我再次想知道为什么会发生这种情况以及这意味着什么。感谢您的帮助。
错误:
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
查询:
IQueryable<User> users = db.Users
.Where(u => u.Email == email)
.Include(cu => cu.CompanyUsers.First())
.Include(c => c.Companies)
.Include(p => p.ParentCompanyAccounts );
【问题讨论】:
-
你能说明
User的定义吗? -
@HamletHakobyan 我之前收到了其他查询,但问题是用户可以在多个公司中,所以在我收到多个结果之前,这就是为什么我先放在那里。生病发布模型的重要部分。谢谢
标签: c# database linq linq-to-entities