var measurementRepository = new MeasurementRepository(); var lastMeasurementsWithHeaderTask = measurementRepository.AsQueryable() .Include(m => m.MeasurementHeader) .Where(m => m.SensorDateTime >= fromTime) .GroupBy(m => m.SensorId) .Select(m => m.FirstOrDefault(x => x.SensorId == m.Key && x.SensorDateTime == m.Max(y => y.SensorDateTime))) .ToListAsync();
219800cookie-checkC# LINQ GroupBy Max DateTime