public static FilteredSamples getSamples(NoiseMapEntities db, RequestSamplesOptions options) { // filter the region if (options == null) { return(new FilteredSamples(db.NOISE_SAMPLE)); } // swap values if start > end if (options.LongitudeStart > options.LongitudeEnd) { var tmp = options.LongitudeStart; options.LongitudeStart = options.LongitudeEnd; options.LongitudeEnd = tmp; } if (options.LatitudeStart > options.LatitudeEnd) { var tmp = options.LatitudeStart; options.LatitudeStart = options.LatitudeEnd; options.LatitudeEnd = tmp; } var filteredData = db.NOISE_SAMPLE.Where(x => x.longitude >= options.LongitudeStart && x.longitude <= options.LongitudeEnd && x.latitude >= options.LatitudeStart && x.latitude <= options.LatitudeEnd); filteredData = applyTimeFilter(options, filteredData); return(new FilteredSamples(filteredData)); }