Is there a best practice for custom paging with ObjectDataSource and OpenAccess ORM?

2 posts, 0 answers
  1. Jin
    Jin avatar
    80 posts
    Member since:
    Jun 2012

    Posted 31 Aug 2012 Link to this post

    Is there a best practice for custom paging with ObjectDataSource and OpenAccess ORM? Because ObjectDataSource  need to provide two method: the one is used to get total record number and another method is used to get all record of selected page. How to write the code with context class and have a good performance?
  2. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 04 Sep 2012 Link to this post

    Hello Jin,

     The performance will be the expected one if you just use the Count() LINQ method to extract the total number of records from the database for a specific entity. Then you should again use LINQ with the Skip() and Take() calls so you can extract the exact records that you want to show in the UI.

    int count = context.Products.Count();
    IList<Product> pageOfProducts = context.Products.Skip(10).Take(10).ToList();


    Regards,
    Zoran
    the Telerik team
    Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
  3. DevCraft banner
Back to Top