我找不到爲什麼會發生以下異常。任何幫助最受讚賞。SkipWhile失敗,「LINQ to Entities does not recognized the method ...」
// EdcsEntities is derived from System.Data.Objects.ObjectContext
EdcsEntities db = new EdcsEntities();
var query = from i in db.Colleges
select i;
query = query.SkipWhile<College>(x => x.CollegeID != 100);
List<College> l = query.ToList<College>();
例外:
LINQ實體無法識別方法 「System.Linq.IQueryable
1[EDCS.ServiceLayer.DataAccess.College] SkipWhile[College](System.Linq.IQueryable
1 [EDCS.ServiceLayer.DataAccess.College], System.Linq.Expressions.Expression1[System.Func
2 [EDCS.ServiceLayer.DataAccess.College,System.Boolean]])' 方法,並且此方法不能轉換爲存儲表達式。
你可能需要'Where'而不是'SkipWhile'。 – Gabe 2010-12-10 19:04:20
只要條件爲真,我想忽略源中的元素,然後返回其餘元素。 – Laura 2010-12-10 19:34:30
你可能會發現[這個問題](http://stackoverflow.com/questions/9227828/how-to-implement-skipwhile-with-linq-to-sql-without-first-loading-the-whole-list)有用。它適用於LINQ to SQL,但它對於LINQ to Entities應該是一樣的。 – 2012-02-13 11:56:21