22
我有以下库方法: -包含路径表达式必须引用的类型所限定的导航属性
public AccountDefinition GetCustomer2(int id)
{
var c = entities.AccountDefinitions
.Where(p=>p.ORG_ID==id)
.Include(a => a.SDOrganization)
.Include(a2 => a2.SiteDefinitions)
.Include(a3 => a3.SDOrganization.AaaPostalAddresses)
.Include(a4 => a4.SiteDefinitions.SelectMany
(a5 => a5.DepartmentDefinitions.SelectMany
(a6 => a6.SDUsers.Select
(a7 => a7.AaaUser))))
.SingleOrDefault();
return c;
}
的它调用上述方法中的以下动作的方法: -
public ActionResult Details2(int id = 0)
{
AccountDefinition cd = repository.GetCustomer2(id);
return View("copy",cd);
}
但当我导航到操作方法时,我在存储库类上出现以下错误: -
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.
那么我的代码有什么问题?
感谢您的答复,但SDOrganization没有。选择。如果我写你的代码,我会得到以下错误: - “”Error 'TMS.Models.SDOrganization'没有包含'Select'的定义,没有扩展方法'Select'接受类型' TMS.Models.SDOrganization“可以找到(你是否缺少使用指令或程序集引用?”“ –
我看到了,那么问题可能是SelectMany,将SelectMany更改为Select。 –
我被卡住了一些其他问题,但我们答案指向正确的方向 –