views:

103

answers:

2

Let's say I have a MS-SQL 2005 table named "People" with the following rows:

|FirstName|LastName|
|JD       |Conley  |
|Joe      |Schmo   |
|Mary     |Jane    |

I want to execute a SQL statement like:

select * from People where FirstName > 'JD'

The problem I'm having is I can't think of a way to get LINQ to SQL to generate this SQL statement. Obviously I can't use ">" and "<" operators on strings in C#.

+2  A: 

Have a look at this question/answer. It shows how to do string comparisons on Linq.

http://stackoverflow.com/questions/578231/issues-doing-a-string-comparison-in-linq

Robin Day
guess it's all about the right search terms. brain not working this monday. :)
JD Conley
Agree completely, that's why I posted the link as an answer rather than voting to close as a duplicate.
Robin Day
+2  A: 

You want String.CompareTo here

var query = from p in db.People
            where p.FirstName.CompareTo("JD") > 0
            select p;
Jason