collection.AsQueryable().Where()有4個重載,分別是:
public static IQueryable<TSource> Where<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate); public static IQueryable<TSource> Where<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, int, bool>> predicate); public static IEnumerable<TSource> Where<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate); public static IEnumerable<TSource> Where<TSource>(this IEnumerable<TSource> source, Func<TSource, int, bool> predicate);由於分頁需要同時查詢數量和列表,就把條件提出來,結果類型錯誤的將條件類型選成了 IEnumerable<TSource>提供的 Func<TSource, bool>,而不是 IQueryable<TSource>提供的 Expression< Func<TSource, bool>>,結果導致條件在C#中篩選、排序。
唉,以后用擴展方法還要看清提供者。
