简体   繁体   English

asp.net MVC 3 DateTime linq

[英]asp.net MVC 3 DateTime linq

I have a table of events, I need a linq query that will return all events from a certain month and year, not day. 我有一个事件表,我需要一个linq查询,该查询将返回特定月份和年份而不是日期的所有事件。

something like 就像是

var monthquery = from c in db.events
                  where c.startdate.month == DateTime(MonthValue, Year Value)
                  select c;

I just don't know the syntax. 我只是不知道语法。 What do I put in instead of MonthValue to get July, for instance? 例如,我要用什么代替MonthValue来获得7月?

Thanks in advance 提前致谢

Instead of MonthValue, you can put the integer that represents the month ... 代替MonthValue,您可以放置​​代表月份的整数...

var monthquery = from c in db.events
                  where c.startdate.month == IntegerThatRepresentTheMonth 
                  && C.startDate.Year == IntegerThatRepresentTheYear
                  select c;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM