Click here to Skip to main content
15,569,696 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

C#
case 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
Posted
Comments
George Swan 23-Jul-15 1:30am    
Have a look at this link
http://blogs.msdn.com/b/csharpfaq/archive/2009/03/25/how-to-use-linq-methods-to-compare-objects-of-custom-types.aspx

Look at https://msdn.microsoft.com/en-us/library/bb352235(v=vs.110).aspx[^] where you can specify the method (MethodInfo) to implement the actual Equality comparison.
 
Share this answer
 

What about converting the strings ToLower or ToUpper before sending them to the Equal expression? Something like:


C#
return Expression.Equal(member.ToString().ToLower(), constant.ToString().ToLower());
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900