Optimize pagination and sorting with ObjectDataSource with EnableCaching = true

I am using an ODS backup (ObjectDataSource) with the Linq-To-SQL class to populate the Gridview on my page.

Given performance, I disabled Viewstate from Gridview and turned on caching in ODS.

In addition, I also optimized the search method in the Linq-to-SQL class to use the .skip and .take methods to retrieve only the "pages" of records.


Now the problem is that, due to caching, ODS cannot sort the recordset on its own. As described in detail in this thread:

GridView sorting doesn't work when I enable caching in Custome Paging and sorting

People recommend using custom sorting and implementing “Comparer,” but I believe that it destroys my performance advantages.

http://forums.asp.net/t/1344883.aspx

I am ready to do a DB trip when sorting, but how to separate it when caching is enabled?

FYI, I already have an AJAX update panel in which I have Gridview (EnableViewstate = false) and ODS (EnableCaching = true). Hope I'm on the right track ... suggestions are welcome.


I need to perform sorting on the application side using "Custom-sort" (these are additional methods for sorting by a common collection of objects). This decision was unacceptable because it required me to pull ALL records from the database, and then sort them!

-, , / , DB. - - , . .skip() .take() LINQ "" .

, , . , , , , .

: "" Gridview. "custom-sort" , ODS . -. orderBy ODS Gridview "". :

odsOrganization.SelectParameters["orderBy"].DefaultValue = GetSortExpr(e.SortExpression);
...
e.Cancel = true;
  • ODS ( - ). ODS . , , 'SelectParameters [ "orderBy" ]' . 'OdsOrganization.SelectParameters [ "OrderBy" ]. DefaultValue' .

, , DefaultValue ODS, , . , ( ) . , !

+3

Source: https://habr.com/ru/post/1732610/


All Articles