views:

56

answers:

2

Possible Duplicate:
string1 >= string2 not implemented in Linq to SQL, any workarround?

To give a brief summary of what I want to achieve we have a table called Application and it stores application version numbers. The contents of that Table for example is

ApplicationID          VersionID
1                      R1.01.01.01
2                      C8.00.00.01
2                      C8.00.00.02
2                      R8.10.00.00
2                      R8.20.00.02
2                      R9.00.00.01
2                      R9.00.00.02
2                      R9.00.00.03
3                      R7.00.30.00

When I am doing this query in TSQL, there are no problems and I get the correct results (Take note that the VersionID is nvarchar type)

Select * From Applications where VersionID >= 'R9.00.00.01' and ApplicationID = 2

but when I start using LINQ to SQL like such

var Applications = from v in db.Applications 
                   where v.VersionID.StartsWith("R") 
                   && v.VersionID >= "R9.00.00.01" 
                   && v.ApplicationID == 2
                   orderby v.VersionID
                   select v;

Then I get the error "Operator >= cannot be applied to operands of type 'string' and 'string'

How do I achive that in LINQ to SQL without changing anything on the database side?

A: 

use

string.Compare(v.VersionID, "R9.00.00.01") >= 0

instead

Mark
+2  A: 

use string.Compare()?

&& string.Compare( v.VersionID , "R9.00.00.01"  ) >= 0
lincolnk
i just wrote the same answer, but i think this is being translated to SQL....that won't work will it?
Mark
@Mark I'm always a little fuzzy on how it translates. This is my best guess and I'll take eat the down arrows if I'm wrong.
lincolnk
@lincolnk - thanks for the quick response it works for me!!!
Raymund