Linq function like .Net string.CompareOrdinal

后端 未结 2 725
陌清茗
陌清茗 2021-01-06 01:29

I need to compare strings using the string.CompareOrdinal(...) inside a linq query.

string max;
string min;

var res = db.Table
            .Whe         


        
2条回答
  •  佛祖请我去吃肉
    2021-01-06 02:18

    If Id is a string, this solution works, so it looks like Id is an int. Int cannot be compared to a string. Change Id to a string or min/max to an int to make it work (and use a simple < and > between the int values).

    By the way: it would save 1 iteration to check for min and max in 1 where function.

提交回复
热议问题