LINQ を使用してビュー モデルにデータを追加する必要があります。私のビュー モデルは次のとおりです。
public class SearchScrapViewModel
{
public WClass wClass{get; set;}
public SClass sClass{get; set;}
public YClass yClass { get; set; }
}
public class WClass
{
public string title { get; set; }
public string link { get; set; }
}
public class SClass
{
public string title { get; set; }
public string link { get; set; }
}
public class YClass
{
public string title { get; set; }
public string link { get; set; }
}
これらの 3 つのクラスを 3 つの異なる LINQ クエリで使用してから、データをreturn View(SearchScrapViewModel);
var wikians = //LINQ Logic
select new SearchScrapViewModel
{
wClass.link = link.Attributes["href"].Value, //Error: I am not able to add to wClass
wClass.title = link.InnerText
};
他のクラスと同様に
return View(SearchScrapViewModel);
次に、このコントローラーのビューで3つのクラスすべてにアクセスできるように渡します
どうやってするか?