Home  /  Questions  /  Question



55   94.7
Nov 09, 2011


WCF Webservice Result Set with Server Side Paging


Are there any patterns or examples on how to implement server side paging for webservice calls that returns large number of records back to the client?



588   99.9
Dec 08, 2011
This is what I use:
public List<BlogApp6.BusinessObjects.Blog> GetAll(
    string sortExpression, int startRowIndex, int maximumRows)
{
    using (var context = DataObjectFactory.CreateContext())
    {
        IQueryable<BlogApp6.DataObjects.EntityFramework.Blog> query = 
            context.Blogs.AsQueryable().OrderBy(sortExpression);
            
        query = query.Skip(startRowIndex).Take(maximumRows);
        
        var list = new List<BlogApp6.BusinessObjects.Blog>();
        
        foreach (BlogApp6.DataObjects.EntityFramework.Blog entity in query)
            list.Add(BlogMapper.ToBusinessObject(entity));
        
        return list;
    }
}

I hope this helps.