“在...之间"在Linq C#中 [英] "Between" in Linq C#

查看:54
本文介绍了“在...之间"在Linq C#中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
运营商之间的LINQ

亲爱的所有,

我需要在LINQ C#中编写此查询.谁能帮我?

Dear All,
Hi,
I need to write this query in LINQ C#. can anyone help me?

Select *  
From Mytable  
where MyText BETWEEN 'john' AND 'Pear'    

推荐答案

我认为此查询应该有效:

I believe this query should work:

var results = yourTable.Where(x => x.Text.CompareTo("john") > 0 && 
                                   x.Text.CompareTo("Pear") < 0);

这假定您要比较表的每一行中的文本,而不是一些预定义的字符串.

This assumes that you want to compare the text in each row of the table, and not some pre-dfined string.

这篇关于“在...之间"在Linq C#中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆