我找不到为什么会发生以下异常。任何帮助最受赞赏。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