使用大于运算符的实体框架字符串

Dou*_*ain 16 c# t-sql entity-framework-4.1

如何让这个查询像在sql中一样工作?在sql中我可以在字符串上使用<>运算符.

我一直在谷歌搜索大约20分钟,但还没有找到解决方案.

我无法将r.ExemptionCode转换为整数,因为它可能具有'91A,9AA,ZZZ,Z01'等值

from r in results
where (r.ExemptionCode > "900"  || r.ExemptionCode == "701" || r.ExemptionCode == "702" || r.ExemptionCode == "721" || r.ExemptionCode == "724")
select r
Run Code Online (Sandbox Code Playgroud)

The*_*aye 29

试试这个 :

from r in results
where (r.ExemptionCode.CompareTo("900") > 0  || r.ExemptionCode == "701" || r.ExemptionCode == "702" ||     r.ExemptionCode == "721" || r.ExemptionCode == "724")
select r
Run Code Online (Sandbox Code Playgroud)

  • 虽然它没有根据答案解决我的问题,但你指出了正确的方向,在我的情况下`String.Compare(a.version,b.version,System.StringComparison.Ordinal)> 0` - 谢谢+1 (3认同)