如何编写 where
语句来选择 Date
字段在 Sunday
到 Saturday
之间的记录给定日期。
Data Fields: Id, Name, Date
最佳答案
date
是相关日期,如何:
DateTime start = date.Date.AddDays(-(int)date.DayOfWeek), // prev sunday 00:00
end = start.AddDays(7); // next sunday 00:00
var qry = from record in data
where record.Date >= start // include start
&& record.Date < end // exclude end
select record;
关于c# - 使用 LINQ 选择本周,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1034952/