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
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
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
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
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