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

Filtering with LINQ to SQL

5 Answers 270 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tonci
Top achievements
Rank 2
Tonci asked on 20 Apr 2008, 05:55 PM

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?

5 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 21 Apr 2008, 10:59 AM
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
0
Adilson
Top achievements
Rank 2
answered on 22 Apr 2008, 05:52 PM
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
0
Sebastian
Telerik team
answered on 23 Apr 2008, 07:08 AM
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
0
Adilson
Top achievements
Rank 2
answered on 23 Apr 2008, 11:30 AM
Hi Stephen

Sorry, I'm using RadGrid + LinqDataSource.

Luiz Roseiro
0
Rosen
Telerik team
answered on 29 Apr 2008, 10:33 AM
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
Tags
Grid
Asked by
Tonci
Top achievements
Rank 2
Answers by
Vlad
Telerik team
Adilson
Top achievements
Rank 2
Sebastian
Telerik team
Rosen
Telerik team
Share this question
or