Issues Doing a String Comparison in LINQ

Try:

var zipLinqQuery =
    from z in db.ZIPMASTERs
    where z.CORP == 12
    && z.ZIPBEG.CompareTo("85546 ") <= 0
    && z.ZIPEND.CompareTo("85546 ") >= 0
    select z;

I don’t know that String.CompareTo works in LINQ to SQL, but it’s the first thing to try.

(Normally you should use a StringComparer to specify the right type of comparison, but I suspect in this case CompareTo is the better option.)

Leave a Comment