0
我有這樣的查詢:如何在包含表達式中選擇一個?
return db.Tanks
.Include(i => i.FluedLevelSensor)
.Include(i => i.WaterLevelSensor)
.Include(i => i.GasPressureSensor)
.Include(i => i.HudrostaticPressureSensor)
.Include(i => i.TechnologicalMaps)
.Include(i => i.TechnologicalGroup)
.Include(i => i.TemperatureSensor).ThenInclude(t => t.TemperatureSensorPoints)
.Include(i => i.Material)
.Include(i => i.TankType)
.Include(i => i.QualityPassports).ThenInclude(i1 => i1.ContentType)
.Include(i=>i.CalibrationTableNew)
.Include(i => i.TankOperations)
.Include(i => i.TankStates).ThenInclude(i => i.State);
我怎麼能寫這樣的:
return db.Tanks
.Include(i => i.FluedLevelSensor)
.Include(i => i.WaterLevelSensor)
.Include(i => i.GasPressureSensor)
.Include(i => i.HudrostaticPressureSensor)
.Include(i => i.TechnologicalMaps.OrderByDescending(o=>o.InsertTime).FirstOrDefault())
.Include(i => i.TechnologicalGroup)
.Include(i => i.TemperatureSensor).ThenInclude(t => t.TemperatureSensorPoints)
.Include(i => i.Material)
.Include(i => i.TankType)
.Include(i => i.QualityPassports.OrderByDescending(o => o.SamplingDate).FirstOrDefault()).ThenInclude(i1 => i1.ContentType)
.Include(i=>i.CalibrationTableNew)
.Include(i => i.TankOperations.OrderByDescending(o => o.OperationStartTime).FirstOrDefault())
.Include(i => i.TankStates.OrderByDescending(o => o.Time).FirstOrDefault()).ThenInclude(i => i.State);
以及是否有任何其他的方法來優化查詢?
豈不是更容易禁用延遲加載此背景下? – wentimo