If you want to convert this to the method syntax version, you can do this step by step. I like to start at the end and work through to the beginning:
-
select
toSelect
defines the source:.Select(g => g.OrderByDescending(s => s.MeasureDate).FirstOrDefault());
-
group
isGroupBy
:.GroupBy(s => s.SensorUnitId) .Select(g => g.OrderByDescending(s => s.MeasureDate).FirstOrDefault());
-
from
the sourceSensorObservationEntities.SensorsMeasures .GroupBy(s => s.SensorUnitId) .Select(g => g.OrderByDescending(s => s.MeasureDate).FirstOrDefault());
solved How to convert linq query to non-query expression?