locked
will I loose efficient server side paging if I change from linqDatasource control to datasource property of databound control? RRS feed

  • Question

  • User-929021816 posted

    Hello,

    was just thinking about implementing methods to return data (the methods would use linq to sql to return ORM objects) instead of using the linqDataSource control for my most common scenarios of binding to my gridviews and listviews etc... I was thinking of doing this because it would simplify searching/filtering features for me by allowing me to create specialized methods but I know it would also require me to handle all the sorting/paging event myselfs, which is fine, but then I remembered the efficient server side paging inbuilt to the linqDataSource control... now I'm not so sure if I should do this. 

    1. the efficient server side paging comes from the linqDataSource control, correct? just because I write a method to return data using linq to sql to bind to a control doesn't mean it will automatically have efficient server side paging... correct?

    2. The only issue I have with the linqDataSource control is that searching becomes overly complex... I wind up having to using the selecting event of the linqDataSource control to write one method with too many flow scenarios to account for whether a user has used various search options on a page. 

    Tuesday, February 7, 2012 11:08 PM

Answers

  • User3866881 posted

    Hello:)

    In my mind,I think Schott Gu has told you that LinqDataSource will store temporarily all the data contents into the memory and it will do Take and Skip。this,if there's less data contents,that's OK;but for many records(thousands of millions of……),This isn't a good way,you should use self-paging(Something like using ASP.NET pager control)。

    Reguards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, February 19, 2012 7:47 PM

All replies

  • User3866881 posted

    1. the efficient server side paging comes from the linqDataSource control, correct? just because I write a method to return data using linq to sql to bind to a control doesn't mean it will automatically have efficient server side paging... correct?

    Not really,Of course you can use LinqDataSource directly——but that's not a real effective side paging——this will first load all the contents into memory and do paging in memory……That's not a common and better way if you have quite a lot of data contents to be paged out……。

    So what I mean is that you can use LINQ's Skip and Take method to do paging,and then with the help of AspNetPager control。you can fetch the specific data contents according to the specific page index。

    Reguards!

    1)Linq's paging:http://msdn.microsoft.com/en-us/library/bb386988.aspx

    2)AspNetPager:AspNetPagerSample.rar

    Thursday, February 9, 2012 9:06 PM
  • User-929021816 posted

    Hello,

    regarding number 1, are you sure about that?

    from:
    http://weblogs.asp.net/scottgu/archive/2007/07/16/linq-to-sql-part-5-binding-ui-using-the-asp-linqdatasource-control.aspx 

    "We will also take advantage of the built-in paging/sorting support within LINQ to SQL to ensure that features like the product listing paging/sorting are performed not in the middle-tier, but rather in the database (meaning only 10 products are retrieved from the database at any given time - we are not retrieving thousands of rows and doing the sorting/paging within the web-server). "

    I actually thought the linqDataSource control was using the linq skip and take methods under the hood?

    I appreciate the response Decker, and the good advice on an alternative way to accomplish server side paging (if I were to replace the use of the linqDataSource control with my own methods), but again, according to Scott Gu's article there the linqDataSource control *is* taking care of that. Can anyone confirm?

    Sunday, February 19, 2012 11:38 AM
  • User3866881 posted

    Hello:)

    In my mind,I think Schott Gu has told you that LinqDataSource will store temporarily all the data contents into the memory and it will do Take and Skip。this,if there's less data contents,that's OK;but for many records(thousands of millions of……),This isn't a good way,you should use self-paging(Something like using ASP.NET pager control)。

    Reguards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, February 19, 2012 7:47 PM