Convert LINQ IQueryable to Page IQueryable Using LINQ to NHibernate

I want to do something like this

public IQueryable GetPaged<TSource>(IQueryable<TSource> query, int startIndex, int pageSize) { return GetSession() .Linq<TSource>() .UseQuery(query) .Take(pageSize) .Skip(startIndex); } 

So, you can put any IQuerable statement and "it will be unloaded" or it will be unloaded.

I am using LINQ for NHibernate. I hope you understand this, swallow this bad English: o

edit: Maybe my approach is wrong, right?

+4
source share
2 answers

This is copied from working code:

 public static class QueryableExtensions { public static IQueryable<T> Paged<T>(this IQueryable<T> source, int page, int pageSize) { return source .Skip((page - 1) * pageSize) .Take(pageSize); } } 
+12
source
 return query.skip(startIndex).take(pageSize); 
0
source

All Articles