tags:

views:

148

answers:

2

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'    
+3  A: 

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.

jjnguy
A: 

Here is how you can do it with ObjectQuery

MytableSet.Where("it.Name between @start and @end", new ObjectParameter("start", "john"), new ObjectParameter("end", "Pear"))

EDIT:

Forget to mention that this statement is specific to Entity Framework not LINQ2SQL.

Oleg I.