爲什麼我得到的錯誤:實體框架 - 「無法創建類型‘閉合式’...的恆定值」的錯誤
Unable to create a constant value of type 'Closure type'. Only primitive types (for instance Int32, String and Guid) are supported in this context.
當我嘗試列舉以下Linq查詢?
IEnumerable<string> searchList = GetSearchList();
using (HREntities entities = new HREntities())
{
var myList = from person in entities.vSearchPeople
where upperSearchList.All((person.FirstName + person.LastName) .Contains).ToList();
}
更新: 如果我嘗試以下方法只是爲了嘗試找出問題,我得到了同樣的錯誤:
where upperSearchList.All(arg => arg == arg)
所以看起來這個問題是與所有的方法,對?有什麼建議麼?
謝謝丹尼爾。對於普通的Linq,相同的語法可以正常工作。所以,它看起來像問題是EF。NET 3.5 SP1的權利? 不帶圓括號的包含相當於: 其中upperSearchList.All(x =>(person.FirstName + person.LastName).Contains(x))。ToList(); – 2009-05-18 21:12:50