使linq表达式不区分大小写 [英] Make linq expression case insensitive
本文介绍了使linq表达式不区分大小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好
我正在尝试使用动态LINQ表达式构建器来自https://gist.github.com/afreeland/6733381
但是我不知道如何使等于操作不区分大小写。
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.
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
推荐答案
看看https://msdn.microsoft.com/en-us/library/bb352235(v=vs.110).aspx [ ^ ]您可以在其中指定方法(MethodInfo)来实现实际的Equality比较。
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.
What about converting the strings ToLower or ToUpper before sending them to the
Equal
expression? Something like:
return Expression.Equal(member.ToString().ToLower(), constant.ToString().ToLower());
这篇关于使linq表达式不区分大小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文