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

FilterDescriptors.Expression Linq format

4 Answers 306 Views
VirtualGrid
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 11 May 2017, 11:21 AM

Hi,

the format of the FilterDescriptors.Expression is for SQL, ie.
"[Filename] LIKE '%3170%'"

But I need to use it in dynamic Linq , so it would be correct:
"Filename.Contains(\"3170\")"

Is there an Option or Tool to get an Linq Expression instead of SQL Expression?

Peter

 

4 Answers, 1 is accepted

Sort by
0
Peter
Top achievements
Rank 1
answered on 11 May 2017, 02:02 PM

I installed the source code and in an debugging session I see, there is only the SQL Syntax implemented in WinControls FilterDescriptor.cs in 

public static string GetExpression(FilterDescriptor filterDescriptor, Function<FilterDescriptor, object> formatValue)
...
                case FilterOperator.Contains:
                    likeValue = DataStorageHelper.EscapeLikeValue(Convert.ToString(filterDescriptor.Value, CultureInfo.InvariantCulture));
                    return string.Format("{0} LIKE '%{1}%'", name, likeValue);
...

 

If not exists a similar Method for Linq Expression I have to make a similar with the Linq format, ie:

return string.Format("{0}.Contains(\"{1}\")",name, likeValue)


Peter

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 12 May 2017, 10:55 AM
Hello Peter, 

Thank you for writing.  

As you have already found out, The Expression property returns the filter in a syntax similar to the SQL one. It is not designed to be used in LINQ. It is necessary to convert manually the expression according to the desired custom format.

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Peter
Top achievements
Rank 1
answered on 12 May 2017, 02:06 PM

Hello Dess,

The Linq query for the cache page get a List<TEntity>. It need much time to convert it to a datatable to access by row/column from CellValueNeeded event. So I convert the the DBSet<TEntity> to SQL and can use the SQL Systax from Filter and Sortexpression.
Only the enclosing # from DateTimes must replaced by '.

Peter

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 15 May 2017, 11:44 AM
Hello Peter, 

Thank you for writing back. 
 
Indeed, this conversion is not an easy task. However, RadGridView supports only expression syntax in one format that resembles SQL. 

If you have any additional questions, please let me know. 

Regards,
Dess
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
VirtualGrid
Asked by
Peter
Top achievements
Rank 1
Answers by
Peter
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or