22
Iは、次のリポジトリの方法を持っている: -ザは、パス式タイプで定義されたナビゲーションプロパティを参照する必要があり
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は.Selectを持っていません。私はあなたのコードを書く場合、私は次のエラーが表示されます: - ""エラー 'TMS.Models.SDOrganization'に 'Select'の定義がなく、 'Select' TMS.Models.SDOrganization 'が見つかりました(使用しているディレクティブまたはアセンブリ参照がありませんか?) " –
問題がSelectManyで、SelectManyがSelectに変更されています。 –
回答は正しい方向に私を指摘しました –