FilterDescriptors.Expression Linq format

5 posts, 0 answers
  1. Peter
    Peter avatar
    51 posts
    Member since:
    May 2016

    Posted 11 May Link to this post

    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

     

  2. Peter
    Peter avatar
    51 posts
    Member since:
    May 2016

    Posted 11 May in reply to Peter Link to this post

    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

  3. Dess
    Admin
    Dess avatar
    2102 posts

    Posted 12 May Link to this post

    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.
  4. Peter
    Peter avatar
    51 posts
    Member since:
    May 2016

    Posted 12 May Link to this post

    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

     

  5. Dess
    Admin
    Dess avatar
    2102 posts

    Posted 15 May Link to this post

    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.
Back to Top