public double FindMaxTempByStationInTimeInterval(Stations station, DateTime begin, DateTime end) { var result = template.QueryAggregate("select MAX(Airtemperature) from Measurements where Station=@station and Timestamp>=@begin and Timestamp<=@end", new[] { new SqlParameter("@station", station.Station), new SqlParameter("@begin", begin), new SqlParameter("@end", end) }); return(Convert.ToDouble(result)); }