嗨,我剛開始學習LINQ和一直在試圖瞭解TakeWhile使用中的LINQ查詢中使用TakeWhile
在這裏,我已經試過這樣的事情
using ( var db = new OrchestrateDataEntities())
{
var y = db.Set<Rulebook_Mapping>();
var xyz = y.TakeWhile(x => x.ID == 2).AsQueryable();
foreach (var item in xyz)
{
Console.WriteLine(item.ID);
}
}
Console.ReadKey();
,然後來到錯誤
LINQ to Entities does not recognize the method 'System.Linq.IQueryable`1[ConFW.Rulebook_Mapping] TakeWhile[Rulebook_Mapping](System.Linq.IQueryable`1[ConFW.Rulebook_Mapping], System.Linq.Expressions.Expression`1[System.Func`2[ConFW.Rulebook_Mapping,System.Boolean]])' method, and this method cannot be translated into a store expression.
只是好奇你爲什麼需要.AsQueryable() –
它沒有沒有工作,並沒有用過,雖然只是用它 – Vivekh