Generated dynamic linq expressions cause all fieldnnames to start with 'it'

2 posts, 0 answers
  1. Charles
    Charles avatar
    4 posts
    Member since:
    Jul 2015

    Posted 10 Aug 2015 Link to this post

    I am using RadFilter on a page connected to a RadGrid in the simplest way.  The RadGrid built in filter generates a correct filterexpression for use in dynamic linq.  However the RadFilter gets everything correct except for the fact that the field names are prefixed with "it."  

    I also decompiled the RadFilter and related code and came across the following code in which it appears that the "it" prefix is very intentional and also very hard-coded.  This is forcing me to put in an event handler to search for the prepended 'it' and remove it.  What is happening here?

     

    :

    public string FormatFieldName(string fieldName, Type dataType, bool isCaseSensitive)
    {
    dataType = RadFilterTypeHelper.GetNonNullableType(dataType);
    if (dataType == typeof (string))
    {
    string str = isCaseSensitive ? "" : ".ToUpper()";
    return string.Format("iif(it.{0}==null,\"\",it.{0}).ToString(){1}", (object) fieldName, (object) str);
    }
    if (!(dataType == typeof (char)))
    return string.Format("it.{0}", (object) fieldName);
    string str1 = isCaseSensitive ? "" : ".ToUpper()";
    return string.Format("Char(iif(it.{0}==null,'''',it.{0})).ToString(){1}", (object) fieldName, (object) str1);
    }

  2. Charles
    Charles avatar
    4 posts
    Member since:
    Jul 2015

    Posted 12 Aug 2015 in reply to Charles Link to this post

    Nevermind, I found another error in my code that was preventing the filter from being applied.  Though I can't find documentation for the dlinq syntax, apparently the "it." prefix is meaningful and works just fine.  The resulting query is correct.
Back to Top