"Between" in Linq C#

c#, linq-to-sql

Solution

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.

Problem

Possible Duplicate: LINQ Between Operator 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' ```

Original source

Related problems