Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to excetute a SQL BETWEEN command in Entity Framework

Just as the title says, I want something in the likes of:

SELECT * FROM TABLE WHERE YEAR BETWEEN 2011 AND 2005;

Any help here?

like image 484
Felix Martinez Avatar asked Apr 15 '12 12:04

Felix Martinez


2 Answers

There is no BETWEEN syntax in linq. So you might have to use something like this:

var result=(
   from t in db.TABLE
   where t.YEAR>=2005 && t.YEAR=<2011
   select t 
);

Where db is the linq data context

like image 84
Arion Avatar answered Oct 11 '22 20:10

Arion


I don't know about a BETWEEN command in sql, but you can always do something like

where year >= 2005 AND year <= 2011
like image 40
ControlAltDel Avatar answered Oct 11 '22 19:10

ControlAltDel