![](/img/trans.png)
[英]EF error Unable to create a constant value of type 'Anonymous type'. Only primitive types or enumeration types are supported in this context
[英]Error: Unable to create a constant value of type 'System.Object'. Only primitive types or enumeration types are supported in this context
我有下面的代碼:
public ActionResult OnDemand()
{
List<SiteMenu> all = new List<SiteMenu>();
using (MyDatabaseEntities dc = new MyDatabaseEntities())
{
all = dc.SiteMenus.Where(a => a.ParentMenuID.Equals(0)).ToList();
}
return View(all);
}
...但出現錯誤:無法創建類型為'System.Object'的常量。 在此上下文中僅支持原始類型或枚舉類型
...錯誤發生在以下行:
all = dc.SiteMenus.Where(a => a.ParentMenuID.Equals(0)).ToList();
關於我做錯了什么,我可以得到一些幫助嗎? ...提前致謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.