Filtering with LINQ to SQL

6 posts, 0 answers
  1. Tonci
    Tonci  avatar
    22 posts
    Member since:
    Oct 2007

    Posted 20 Apr 2008 Link to this post

    I’m using RadGrid for ASP.NET AJAX with LinqDataSource.

    I’m amazed with amount of functionality I can accomplish in this combination with just declarative programming in ASCX and without single line in code behind.

    What I really like is that sorting and paging is done on SQL server. Here is example of T-SQL I got from SQL Server Profiler:

    exec sp_executesql N'SELECT [t1].[Id], [t1].[ParentId], [t1].[Name]
    FROM (
        SELECT ROW_NUMBER() OVER (ORDER BY [t0].[Name]) AS [ROW_NUMBER], [t0].[Id], [t0].[ParentId], [t0].[Name]
        FROM [dbo].[Things] AS [t0]
        ) AS [t1]
    WHERE [t1].[ROW_NUMBER] BETWEEN @p0 + 1 AND @p0 + @p1
    ORDER BY [t1].[ROW_NUMBER]',N'@p0 int,@p1 int',@p0=8,@p1=8
     

    Now, I would like to utilize RadGrid filtering with AllowFilteringByColumn="True".

    When I execute some filter I got this T-SQL code in SQL Profiler:

    SELECT TOP (2147483647) [t0].[Id], [t0].[ParentId], [t0].[Name]
    FROM [dbo].[Things] AS [t0]
    ORDER BY [t0].[Name]

    This means that in this case filtering and paging is not done by SQL server, but on web server with in RadGrid control. In this case it is possible that huge amount of rows is sent form SQL to web server and I would like to avoid this too. (I see that with canretrievealldata="False" I can preserve SQL Server paging, but in this case filtering is preformed only over current page, so this is not a solution for me.)

    If I understand correctly by default data filtering is executed with in RadGrid control with LINQ.

    I would like to use LINQ to SQL for this in my project because I think it is more optimal.

    Do I miss something here?

    What is best way to accomplish use of LINQ to SQL with RadGrid for ASP.NET AJAX and LinqDataSource for filtering also?

  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 21 Apr 2008 Link to this post

    Hi Tonci,

    When the grid is grouped, filtered or sorted will pass int.MaxValue to the DataSourceControl in order to retrieve all data needed for the next operations. You can check this example where the grid is bound to 1mil.records and will sort, page and filter instantly even with disabled server-side paging:
    http://www.telerik.com/DEMOS/ASPNET/Prometheus/Grid/Examples/GeneralFeatures/ASPNET35/DefaultCS.aspx

    Regards,
    Vlad
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Adilson
    Adilson avatar
    2 posts
    Member since:
    Apr 2008

    Posted 22 Apr 2008 Link to this post

    Hi,

    I have the same problem using RadView with LinqDataSource.

    I need the filters using Where clause from Linq. How i do this? Its possible?

    thanks,


    Luiz Roseiro
  5. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 23 Apr 2008 Link to this post

    Hi Luiz,

    Can you please specify to which from our controls you are referring as RadView? Thus we will do our best to provide an accurate answer for you.

    Best regards,
    Stephen
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Adilson
    Adilson avatar
    2 posts
    Member since:
    Apr 2008

    Posted 23 Apr 2008 Link to this post

    Hi Stephen

    Sorry, I'm using RadGrid + LinqDataSource.

    Luiz Roseiro
  7. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 29 Apr 2008 Link to this post

    Hi Luiz,

    If you want to handle filtering with your custom logic instead through RadGrid's internal logic you can hook to ItemCommand event, check if the current command is filtering and if so cancel it and handle the filtering on your own. More information on filtering can be found in online documentation here.

    Greetings,
    Rosen
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017