我有一张这样的表
Id MachineName ServerName TagName TagValue ValueDateTime
1 DanPac_A Daniel.Device Links.1 Poll.Registers Block 0.STR02_METER_DENSITY_(1) 93.1631400000 2018-06-04 21:08:28.720
2 DanPac_A Daniel.Device Links.1 Diagnostics.Heartbeat 1.0000000000 2018-06-04 21:08:32.717
3 DanPac_A Daniel.Device Links.1 Poll.Registers Block 0.310-TT-302_(6) 52.1062000000 2018-06-04 21:08:32.873
4 DanPac_A Daniel.Device Links.1 Poll.Registers Block 0.310-TT-302_(6) 52.1062000000 2018-06-04 21:08:32.873
5 DanPac_A Daniel.Device Links.1 Poll.Registers Block 0.310-TT-302_(7) 16.8916200000 2018-06-04 21:08:32.873
6 DanPac_A Daniel.Device Links.1 Poll.Registers Block 0.310-TT-302_(7) 16.8916200000 2018-06-04 21:08:32.873
7 DanPac_A Daniel.Device Links.1 Poll.Registers Block 0.310-TT-302_(7) 16.8916200000 2018-06-04 21:08:32.873
8 DanPac_A Daniel.Device Links.1 Poll.Registers Block 0.310-TT-302_(7) 16.8916200000 2018-06-04 21:08:32.873
9 DanPac_A Daniel.Device Links.1 Poll.Registers Block 0.310-TT-302_(6) 52.1062000000 2018-06-04 21:08:32.873
10 DanPac_A Daniel.Device Links.1 Poll.Registers Block 0.310-TT-302_(7) 16.8916200000 2018-06-04 21:08:32.873
11 DanPac_A Daniel.Device Links.1 Poll.Registers Block 0.310-TT-302_(6) 52.1062000000 2018-06-04 21:08:32.873
12 DanPac_A Daniel.Device Links.1 Poll.Registers Block 0.310-TT-302_(7) 16.8916200000 2018-06-04 21:08:32.873
13 DanPac_A Daniel.Device Links.1 Poll.Registers Block 0.310-TT-302_(6) 52.1062000000 2018-06-04 21:08:32.873
14 DanPac_A Daniel.Device Links.1 Poll.Registers Block 0.310-TT-302_(7) 16.8916200000 2018-06-04 21:08:32.873
15 DanPac_A Daniel.Device Links.1 Poll.Registers Block 0.310-TT-302_(7) 16.8916200000 2018-06-04 21:08:32.873
16 DanPac_A Daniel.Device Links.1 Poll.Registers Block 0.310-TT-302_(6) 52.1062000000 2018-06-04 21:08:32.873
17 DanPac_A Daniel.Device Links.1 Poll.Registers Block 0.310-TT-302_(7) 16.8916200000 2018-06-04 21:08:32.873
18 DanPac_A Daniel.Device Links.1 Poll.Registers Block 0.310-TT-302_(6) 52.1062000000 2018-06-04 21:08:32.873
19 DanPac_A Daniel.Device Links.1 Poll.Registers Block 0.310-TT-302_(6) 52.1062000000 2018-06-04 21:08:32.873
20 DanPac_A Daniel.Device Links.1 Poll.Registers Block 0.310-TT-302_(6) 52.1062000000 2018-06-04 21:08:32.873
数据以24小时时间格式登录到服务器,间隔为5秒,我需要根据用户选择的时间间隔将其聚合为每小时,每周,每日,每分钟。
我可以通过datediff来区分间隔,我的查询是如何使用linq to entities查询将此表聚合成任何上述格式。
e.g。如果用户从6-jun-2018:09:24:111到7-jun-2018:09:25:00选择日期范围,那么查询应该返回
“MachineName,ServerName,TagName,TagValue(当时的平均值),ValueDateTime(每小时,即6-jun-2018:09:24,6-jun-2018:10:24 ..)
任何帮助..