You must Sign In to post a response.
  • Category: LINQ

    Make linq case insensitive

    Make linq case insensitive
    23 minutes ago|LINK

    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
  • #760883
    Hello,

    I am not much aware about LINQ in depth.

    But you can do the following :

    System.Collections.CaseInsensitiveComparer
    ------------------------
    System.StringComparer.OrdinalIgnoreCase
    ------------------------

    string.Equals(member, constant, StringComparison.CurrentCultureIgnoreCase);

    ------------------------

    StringComparer.CurrentCultureIgnoreCase.Equals(member, constant)

    ------------------------

    StringComparer.CurrentCultureIgnoreCase.Compare(member, constant)


    Hope this will help you.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"


  • Sign In to post your comments