How to extract SQL BETWEEN command in Entity Framework

As the name says, I want something like:

SELECT * FROM TABLE WHERE YEAR BETWEEN 2011 AND 2005;

Any help here?

+5
source share
2 answers

There is no syntax in linq BETWEEN. Therefore, you may 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

+4
source

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

where year >= 2005 AND year <= 2011
+1
source

All Articles