locked
Make linq case insensitive RRS feed

  • Question

  • User-453856459 posted

    Hello

    I am trying to use the dynamic LINQ expression builder from https://gist.github.com/afreeland/6733381

    However the I am not sure how to make the "equals" operation case insensitive. 

    ase GridHelper.Operator.Equals:
                    return Expression.Equal(member, constant);

    I want the above to be case insensitive either convert both to lower case or upper case, does not matter.

    Pls. any helpful pointers appreciated.

    Thanks

    Wednesday, July 22, 2015 4:42 PM

Answers

All replies

  • User281315223 posted

    You may be able to change both values being compared to lower or uppercase respectively (but only if you were using strings) :

    return Expression.Equal(member.ToLower(), constant.ToLower());

    This related discussion discusses a few different workarounds to handle this (such as by using the StringComparison.IgnoreCase attribute when performing string comparisons) however it really just depends.

    Wednesday, July 22, 2015 6:27 PM
  • User-453856459 posted

    Thanks but I followed the suggestion from this thread.

    http://www.telerik.com/forums/filter-is-case-sensitive-how-do-i-change-that   

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 24, 2015 3:55 PM