所以我想要做的是获取数据库中的条目数,这些条目形成一个选定日期,从当天所在的那一周开始。数据库列和我的变量都是datetime字段。 我的约会方法是:
private int multiUse_timesInADay()
{
daydate date = currentDate.date;
var submitCount = from campaignMessages in dcCRData.Mytable
where campaignMessages.Created == date
select campaignMessages;
int count = submitCount.Count();
return count;
}
我对如何进行周搜索感到失望。 有什么想法吗?
答案 0 :(得分:0)
//first get to the last monday i.e. start of the week
int delta = DayOfWeek.Monday - currentDate.date.DayOfWeek;
DateTime monday = currentDate.date.AddDays(delta);
var submitCount = from campaignMessages in dcCRData.Mytable
where campaignMessages.Created >= monday && campaignMessages.Created <= monday.AddDays(7)
select campaignMessages;