I've done the PaginatedList as the following but I'm trying to display the result of query (it's an sqlserver view that I've drag and drop to do it as a table Model) and there's something that is changing the order I've specified in the query. The AddRange
or the Take... because before I debugged and I could see that the order is good until the source object.
public PaginatedList(IQueryable<T> source, int pageIndex, int pageSize)
{
PageIndex = pageIndex;
PageSize = pageSize;
TotalCount = source.Count();
TotalPages = (int)Math.Ceiling(TotalCount / (double)PageSize);
this.AddRange(source.Skip(PageIndex * PageSize).Take(PageSize));
}
aspnetiano
Member
309 Points
183 Posts
Paginated List problem
Feb 29, 2012 06:46 PM|LINK
Hi!
I've done the PaginatedList as the following but I'm trying to display the result of query (it's an sqlserver view that I've drag and drop to do it as a table Model) and there's something that is changing the order I've specified in the query. The AddRange or the Take... because before I debugged and I could see that the order is good until the source object.
public PaginatedList(IQueryable<T> source, int pageIndex, int pageSize) { PageIndex = pageIndex; PageSize = pageSize; TotalCount = source.Count(); TotalPages = (int)Math.Ceiling(TotalCount / (double)PageSize); this.AddRange(source.Skip(PageIndex * PageSize).Take(PageSize)); }Mark as answered, please.
ignatandrei
All-Star
135204 Points
21687 Posts
Moderator
MVP
Re: Paginated List problem
Feb 29, 2012 09:04 PM|LINK
No one is changing. However, you can pass an IOrderedQueryable - to be sure about the order.
aspnetiano
Member
309 Points
183 Posts
Re: Paginated List problem
Mar 01, 2012 09:55 PM|LINK
Ok, thank you!
I've used the db.Model.OrderBy(...); instead of db.Model; and that worked.
Thanks again for pointing me on the solution.
Mark as answered, please.