【发布时间】:2017-07-28 10:50:30
【问题描述】:
我想获取上午 7 点到下午 3 点之间的记录。如何编写相同的 linq 查询?
代码
var items = Pirs.Where(a => !a.dataFrame.EndsWith("AAAAAAAAAAA=") && (fromDate == null || fromDate.Value.Date <= TimeZoneInfo.ConvertTimeFromUtc(Convert.ToDateTime(a.timestamp), TimeZoneInfo.FindSystemTimeZoneById("India Standard Time")).Date) && (toDate == null || toDate.Value.Date >= TimeZoneInfo.ConvertTimeFromUtc(Convert.ToDateTime(a.timestamp), TimeZoneInfo.FindSystemTimeZoneById("India Standard Time")).Date) && (a.timestamp.Hour > 7 || a.timestamp.Hour < 15))
.GroupBy(a => a.dataFrame.Substring(a.dataFrame.Length - 12))
.Select(g => g.First()).OrderBy(a => a.timestamp);
样本数据
timestamp "2017-07-21T14:06:02.203Z"
【问题讨论】:
标签: c# linq model-view-controller