2 つの異なるドロップダウン リストがあり、それぞれに適切な情報を返す select ステートメントがあります。いくつかの問題が発生しています:
selectステートメントからの結果をどの形式で適切に返す必要がありますか?
最初のドロップダウン リストで選択されたアイテムの ID に基づいて、2 番目のドロップダウン リストの select ステートメントを制御しますか。
サービス層: 1 番目のドロップダウン リスト
public IEnumerable<ContentVw> GetSections()
{
using (var db = my connection info)
{
var sections = (from e in db.Table1
join re in db.RootTables re
on e.ID equals re.Table1ID
where re.ChairID == 1
select new { e.DisplayName, e.ID, e.GUID };
return sections;
}
}
エラー: IQueryable 匿名を ...ContentVw に変換できません
2 番目のドロップダウン リスト
public IEnumerable<ContentVw> GetContent(int itemId) //itemId = first dropdown list selection
{
using (var db = my connection info)
{
var content = (from e in db.Table1 join em in db.TableToTableMaps on e.ID equals em.KnowsTableID where em.TableID == itemId select new { e.DisplayName, e.ID, e.GUID });
}
}
コンテンツビュー:
public partial class ContentVw
{
public string Name { get; set; }
public int Id { get; set; }
public Guid GUID { get; set; }
}
コントローラ
public ActionResult ContentManage()
{
var _sections = new ContentService().GetSections().ToList();
ViewBag.SectionsDropdown = _sections;
return View();
}