LINQ 查询多个日期并计算行数
你好,我想知道如何使用 LINQ 做两件事 这个问题可能更多是一个 SQL/C# 问题,我首先想查询多个日期 我该怎么做?
例如,我想在 DateTime SQL 列中查询 2011 年的每个日期,所以我想找到 01/01/2011 到 31/12/2011 我想我会用 ##/##/ 等内容替换第一天的月份数字2011
其次,我如何计算行数会像这样“var rowCount = qRows.Count();”
谢谢
Hi I want to know how to do two things with LINQ
This question is probably more a SQL/C# thing I firstly want to query with multiple dates
How would I do this?
For example I want to query every date in 2011 in a DateTime SQL Column So I want to find 01/01/2011 to 31/12/2011 I guess I would replace the first day month numbers with something e.g ##/##/2011
Secondly how do I count rows would it be like this "var rowCount = qRows.Count();"
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
试试这个:
try this :
你也可以做 x.Count
you can also do x.Count
您可以根据需要重复执行
myDate.AddDays(1)
多次。是的,您可以对返回的 LINQ 数据集执行 Count()。
You can do
myDate.AddDays(1)
repeated as many times as necessary.Yes, you can do a Count() on the returned LINQ dataset.
与之前的答案略有不同(例如,如果您从另一个对象中提取日期):
Slightly different take on earlier answer(if you were pulling the date from another object for instance):