Skip to content

Instantly share code, notes, and snippets.

@enisn
Last active April 10, 2021 10:42
Show Gist options
  • Save enisn/2ebf672c8d850b913b759b464e5ff07a to your computer and use it in GitHub Desktop.
Save enisn/2ebf672c8d850b913b759b464e5ff07a to your computer and use it in GitHub Desktop.
AutoFilterer.Generators | Step 2 | WeatherForecast.cs
[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