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

本文关键字:实体 框架 字符串 运算符 大于 | 更新日期: 2023-09-27 18:25:15

如何使此查询像在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

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

尝试使用.CompareTo():

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