This project is read-only.
1
Vote

PagedList - Skip without Sort is LinqToSQL specific

description

EF4 throws a fit when calling source.Skip().* without OrderBy, and because it's not strongly typed, it's difficult to choose a specific property to sort by!

This is godawful but "works":
        var list = from i in source
                   select i;

        var resultsList = list
            .Skip(index * pageSize)
            .Take(pageSize)
            .ToList();

        this.AddRange(resultsList);

comments

hawaii wrote Aug 23, 2010 at 5:18 PM

there is a way to work around this:
change :
this.AddRange(source.Skip(index * pageSize).Take(pageSize).ToList());
to:
this.AddRange(source.AsEnumerable().Skip(index * pageSize).Take(pageSize).ToList());