public async Task <IActionResult> Get() { var analytics = from p in _analyticsRepository.GetAll() select p; var panel = from p in _panelRepository.GetAll() select p; var result = from a in analytics join p in panel on a.PanelId equals p.Id where a.DateTime < DateTime.Today group a by new { a.PanelId, a.DateTime } into analPanel select new { PanelID = analPanel.Key.PanelId, Date = analPanel.Key.DateTime, Sum = analPanel.Sum(x => x.KiloWatt), Avg = analPanel.Average(x => x.KiloWatt), Min = analPanel.Min(x => x.KiloWatt), Max = analPanel.Max(x => x.KiloWatt) }; return(Ok(result)); }