This is a migrated thread and some comments may be shown as answers.

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

1 Answer 51 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jin
Top achievements
Rank 1
Jin asked on 31 Aug 2012, 09:17 AM
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?

1 Answer, 1 is accepted

Sort by
0
Zoran
Telerik team
answered on 04 Sep 2012, 03:11 PM
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!
Tags
General Discussions
Asked by
Jin
Top achievements
Rank 1
Answers by
Zoran
Telerik team
Share this question
or