views:

159

answers:

1

I have an example in SQL how to use the same logic in Linq to Entity?

SELECT * FROM TABLE WHERE DATE BETWEEN STARTDATE AND ENDDATE 
+1  A: 

I'm assuming C#.

DateTime startDate=bla;
DateTime endDate=blabla;
using(var db=new MyDataContext())
{
    var filteredData=db.TABLE.Where(t => t.DATE > startDate && t.DATE < endDate);
    //...
}
spender
Use `>=` and `<=` to give the same results as `BETWEEN`, though.
Craig Stuntz
I never use BETWEEN for exactly this reason. I prefer the explicitness of the other form.
spender