Last active
April 10, 2021 10:42
-
-
Save enisn/2ebf672c8d850b913b759b464e5ff07a to your computer and use it in GitHub Desktop.
AutoFilterer.Generators | Step 2 | WeatherForecast.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpGet] | |
public IEnumerable<WeatherForecast> Get([FromQuery]WeatherForecastFilter filter) | |
{ | |
var rng = new Random(); | |
// Change range to 100 from 5 to get more reasonable results. | |
return Enumerable.Range(1, 100).Select(index => new WeatherForecast | |
{ | |
Date = DateTime.Now.AddDays(index), | |
TemperatureC = rng.Next(-20, 55), | |
Summary = Summaries[rng.Next(Summaries.Length)] | |
}) | |
.AsQueryable().ApplyFilter(filter) // Apply auto-filter to query | |
.ToArray(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment