Advertisement
Guest User

Untitled

a guest
Jan 12th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. public class Device
  2. {
  3. [Key]
  4. public int Id { get; set; }
  5.  
  6. public class DeviceStatus
  7. {
  8. [Key]
  9. public int Id { get; set; }
  10.  
  11. [...]
  12. public Device Device { get; set; }
  13. }
  14.  
  15. var statusMac =
  16. from status in actiContext.DeviceStatus.OfType<DeviceStatus>().Include(s => s.Device)
  17. where status.Device.Mac == mac
  18. select status
  19. ;
  20.  
  21. var lastStatusMac =
  22. from status in statusMac
  23. group status by status.Device.Id
  24. into g
  25. select g.Where(s1 => s1.TimeStamp == g.Max(s2 => s2.TimeStamp));
  26.  
  27. var lastStatusMac =
  28. from status in statusMac**.toList()**
  29. group status by status.Device.Id
  30. into g
  31. select g.Where(s1 => s1.TimeStamp == g.Max(s2 => s2.TimeStamp));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement