萌新求教:关于linq限定时间段 查询数据库记录的办法.....
net吧
全部回复
仅看楼主
level 1
飞飞韩erth 楼主
//linq语句根据时间段获取实验记录信息
public IEnumerable GetDetailByTime(DateTime start, DateTime end)
{
try
{
return datacontex.LabBookInf.Where(d => d.Btime >= start && d.Otime <= end).AsEnumerable();
}
catch (Exception ex)
{
throw ex;
}
}
//button事件
protected void Button1_Click(object sender, EventArgs e)
{
LabBookInf bra = new LabBookInf();
RcordManager bro = new RcordManager();
DateTime a = Convert.ToDateTime(time_start.Text);
DateTime b = Convert.ToDateTime(time_end.Text);
IEnumerable c = bro.GetDetailByTimeAndName(a, b);
var data = c;
this.GridView1.DataSource = data;
this.GridView1.DataBind();
}
//求大神看看为什么只能查询数据库的第一条记录 其它的都查不出来?
2017年04月02日 07点04分 1
1