In SQL you have the ability to write a query that executes a between on a column that is of type ‘nvachar’ and simply returns to you all the rows that are between the min and max values specified.
For Example,
Table (Id:Int, Name:nvarchar):
Contents:
1, Annie
2, Bill
3, Frank
4, Phil
5, Ted
Select * where Name Between 'Frank' and 'Ted'
Should return Frank, Phil, and Ted.
Is there a way to do this with linq or am I going to have to create a custom query and execute it? The only examples I have seen involve dates or integers which make it very easy (can use the comparison operators like <, > etc).
You’d use
CompareToinstead:Use
>and<to be exclusive (i.e. to exclude Frank and Ted).Basically it’s the same as using
<and>, but with methods 🙂