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

Operating with the FilterExpression - convert from Linq to SQL syntax

3 Answers 379 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vasssek
Top achievements
Rank 1
Vasssek asked on 01 Jan 2014, 08:59 AM

Hello,


I have issue with RadGrid1.MasterTableView.FilterExpression. I have to use parametrized stored procedures in my project. In the RadGrid, there are some numeric columns which I want to have CurrentFilterFunction="Contains". Because of that  EnableLinqExpressions has to be set to true.


The result is, that value in the FilterExpression is shown in the Linq syntax instead of SQL syntax:


Linq: "(it[\"SAP_sklad\"].ToString().ToUpper().Contains(\"01\".ToUpper()))"

SQL: "([SAP_sklad] LIKE '%01%')";



Does somebody know, how can I easily convert a FilterExpression value from linq format to standard SQL format ?

I've found this link, where are exactly described all differences between Linq and SQL.

http://www.telerik.com/help/aspnet-ajax/grid-operate-with-filter-expression-manually.html



Please, help me to solve this issue.







Thank you







Best regards



Vasssek



3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 01 Jan 2014, 06:22 PM
Hello Vaclav,

Maybe one of the simplest approaches would be to use a profiler to see the generated query.
Alternative solutions are listed here:
how to convert linq query to sql

Regards,
Daniel
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Vasssek
Top achievements
Rank 1
answered on 02 Jan 2014, 11:11 AM

Hello,



Your suggestion can be used when there is filter type or filter value set by one column. But what if our users will set multi column filter or set each time different columns filter combination ? SQL profiler couldn't help in this case...



I want do dynamically convert from this:

"(it[\"artikel\"].ToString().ToUpper().Contains(\"0613\".ToUpper())) AND (it[\"SAP_sklad\"].ToString().ToUpper().Contains(\"010\".ToUpper()))"



to this:

"artikel LIKE '%0613%' AND SAP_sklad LIKE '%010%'";



of course, there can be other variations based on RadGrid column filter function:

StartsWith

EndsWith

EqualTo


...

...



Based on your conversion table from this link http://www.telerik.com/help/aspnet-ajax/grid-operate-with-filter-expression-manually.html I want to ask you to provide c# method or class which could allow me to convert RadGrid1.MasterTableView.FilterExpression value from linq format to standard SQL format.



Please help...



Thank you



Vasssek







0
Accepted
Angel Petrov
Telerik team
answered on 07 Jan 2014, 09:39 AM
Hi Vasssek,

I am sorry to say but providing such a class/convertor is out of our support scope. The issue is not directly related to RadGrid and is rather a general programming problem.

What I can suggest is to include an external library which can convert the expressions. As a starting point I suggest that you examine this toolkit.

Regards,
Angel Petrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Vasssek
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Vasssek
Top achievements
Rank 1
Angel Petrov
Telerik team
Share this question
or