Search code examples
c#linqlinq-to-sql

LINQ to SQL value BETWEEN two double values


I'm using LINQ to SQL to query my database, I have a query very similar to this:

var result = from db.MyTable.Where(d => (double)d.Price >= minValue)

I need the where clause to have a d.Proce >= minValue, and d.Price =< maxValue (like a T-SQL BETWEEN clause).

How can I do this?


Solution

  • How about this:

    var result = from db.MyTable.Where(d => (double)d.Price >= minValue 
                                             && (double)d.Price <= maxValue)