![](/img/trans.png)
[英]Entity Framework, unable to create a constant value of type 'XX'. Only primitive types or enumeration types are supported in this context
[英]Linq to Entity Framework : unable to create a constant value of type ''. Only primitive types or enumeration types are supported in this context
我正在嘗試從一個表中獲取 select,其中列表包含使用 linq 和實體框架的值。 但它告訴我它不能創建常量並拋出異常。 如果您注釋掉 && 列表部分,它可以正常工作。 我究竟做錯了什么?
var DbQry = (from data in Db.ACCESS
where data.Active == true
&& List.Select(s => s.Study).Contains(data.Study)
&& List.Select(s => s.System).Contains(data.System)
select data).ToList();
我假設Study
和System
屬性是類(而不是原始類型),而List
是用戶定義的變量。
如果是這樣,您可以嘗試與List.Select(s => s.Study.Id).Contains(data.Study.Id)
等標識符進行比較嗎
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.