[英]How to return LINQ query to View Model
所以我的控制器中有以下操作:
public ActionResult List() {
ViewBag.Title = "View Current Stores";
var curStores =
(from store in stores.Stores
where store.CompanyID == curCompany.ID
select store).ToList();
return View(curStores);
}
假定獲取商店列表並將其呈現為視圖表。 但是,LINQ語句引發以下錯誤:
Non-static method requires a target.
我該怎么辦?
嘗試使用stores.Stores.Where(o=>o.CompanyID==curCompany.ID).ToList()
; 但是請確保操作中使用但未定義的其他變量(即curCompany和store)是有效變量。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.