csdn112233445566
里约儿
2019-04-18 09:07

EF 按时、按天、按周、按月查询数据怎么实现

  • c#
  • mvc
  • sql

//获取当天所有时间段的条件数据
for (int i = 0; i < 24; i++)
{
DateTime temp = new DateTime(endTime.Year, endTime.Month, endTime.Day, i, 0, 0);
int tag = temp.Hour;
flowWhere = (m) => m.WebInfo.Id == webId && m.DeviceType.Contains(device) && SqlFunctions.DateDiff("hh", temp, m.CurrentTime) == 0;
vifWhere = (m) => m.WebInfo.Id == webId && m.DeviceType.Contains(device) && SqlFunctions.DateDiff("hh", temp, m.AccessTime) == 0 || m.VisitSE == source || m.Address == territory;
TimeSpan ts = new TimeSpan(temp.Hour, 0, 0);
VisitorInfo model = new VisitorInfo();
model.Address = ts.ToString();
model.Age = tag;
se.Add(model);
VisitorInfo visitor = sm.GetHourByExpression(vifWhere, flowWhere);
UV.Add(visitor);
}
se = se.OrderBy(m => m.Address).ToList();
}

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答