C# Linq to DataTable查询缺少结果集中的第一条记录 DateTime start=d.Key;//比如说2013-06-01 DateTime end=d.Key.AddDays(d.Value);//假设结束=2013-06-07 var filteredRecords=从n到dt.AsEnumerable() orderby n[“日期”]升序 其中(DateTime)n[“Date”]>=start&&(DateTime)n[“Date”]
尝试仅使用日期的一部分进行比较:C# Linq to DataTable查询缺少结果集中的第一条记录 DateTime start=d.Key;//比如说2013-06-01 DateTime end=d.Key.AddDays(d.Value);//假设结束=2013-06-07 var filteredRecords=从n到dt.AsEnumerable() orderby n[“日期”]升序 其中(DateTime)n[“Date”]>=start&&(DateTime)n[“Date”],c#,linq,datatable,C#,Linq,Datatable,尝试仅使用日期的一部分进行比较: DateTime start = d.Key; // say 2013-06-01 DateTime end = d.Key.AddDays(d.Value); // say end=2013-06-07 var filteredRecords = from n in dt.AsEnumerable() orderby n["Date"] ascending where (
DateTime start = d.Key; // say 2013-06-01
DateTime end = d.Key.AddDays(d.Value); // say end=2013-06-07
var filteredRecords = from n in dt.AsEnumerable()
orderby n["Date"] ascending
where (DateTime)n["Date"] >= start && (DateTime)n["Date"] <= end
select n;
来自dt.AsEnumerable()中的r
let date=r.字段(“日期”)
其中date.date>=start.date&&date.date尝试仅使用日期的一部分进行比较:
DateTime start = d.Key; // say 2013-06-01
DateTime end = d.Key.AddDays(d.Value); // say end=2013-06-07
var filteredRecords = from n in dt.AsEnumerable()
orderby n["Date"] ascending
where (DateTime)n["Date"] >= start && (DateTime)n["Date"] <= end
select n;
来自dt.AsEnumerable()中的r
let date=r.字段(“日期”)
其中date.date>=start.date和date.datevar recs=dt.AsEnumerable()。其中(x=>x.Field(“日期”)>=start和x.Field(“日期”)x.Field(“日期”);
var recs=dt.aseneumerable()。其中(x=>x.Field(“日期”)>=start&&x.Field(“日期”)x.Field(“日期”);
什么是d
?您确定d.Key
的值正好是2013-06-01
?我的意思是可能会有几分钟和几秒钟?应用于n[“Date”]
…d的相同逻辑是字典对象。是的,它是2013-06-01,我已经使用断点检查了visual studio。您应该尝试从第一条记录中提取值,并将其与d.Key
进行比较,以查看它们是否匹配。如果不是,就是这样。什么是d
?您确定d.Key
的值正好是2013-06-01
?我的意思是可能会有几分钟和几秒钟?应用于n[“Date”]
…d的相同逻辑是字典对象。是的,它是2013-06-01,我已经使用断点检查了visual studio。您应该尝试从第一条记录中提取值,并将其与d.Key
进行比较,以查看它们是否匹配。如果没有,那就是问题了。太棒了,这很管用了。拉兹别列佐夫斯基先生,谢谢你,救了我一天:)+1用于让日期=…
。查询语法的最大好处之一。太棒了,这很管用了。拉兹别列佐夫斯基先生,谢谢你,帮我省了不少钱:)+1用于let date=…
。查询语法的最大好处之一。
var recs = dt.AsEnumerable().Where(x=>x.Field<DateTime>("Date") >= start && x.Field<DateTime>("Date") <= end)
.OrderBy(x => x.Field<DateTime>("Date"));