2 つの結合を含むクエリを作成しようとしています。
- 1 つの StoryTemplate に複数のストーリーを含めることができます
- 1 つのストーリーは複数の StoryDrafts を持つことができます
StoryDrafts オブジェクトでクエリを開始しています。これは、それが UserId にリンクされている場所だからです。
StoryDrafts オブジェクトから StoryTemplates オブジェクトへの直接の参照はありません。このクエリを正しく作成するにはどうすればよいですか?
public JsonResult Index(int userId)
{
return Json(
db.StoryDrafts
.Include("Story")
.Include("StoryTemplate")
.Where(d => d.UserId == userId)
,JsonRequestBehavior.AllowGet);
}
助けてくれてありがとう。