日期:2014-05-20  浏览次数:20706 次

linq to sql 查询时间段问题
有数据:
 aaaaa  2012-02-10  
 bbbbb  2012-02-11 
 ccccc  2012-02-12
dddddd  2012-02-13

我要查询 从 2012-02-10 到 2012-02-12
之间的数据

linq 语句怎么写呢?
------解决方案--------------------

(from i in table
where i.data>="2012-02-10"
where i.data<"2012-02-12"
select i).ToList();

------解决方案--------------------
引用:
  name   date
 aaaaa  2012-02-10  
 bbbbb  2012-02-11 
 ccccc  2012-02-12
dddddd  2012-02-13


var query=from q in db.test
where q.date>=DateTime.Parse('2012-02-10') &&  q.date<=DateTime.Parse('2012-02-13')
select q