I have a get method like this...
[HttpGet]
public async Task<ActionResult<IEnumerable<Customer>>> GetCustomers()
{
var queryString = HttpContext.Request.Query;
return await _context.Customers.Take(7).ToListAsync();
}
and I want to pass in a query string like this:
https://localhost:44315/api/customer?param1=1¶m2=String Value
I would like to do this without having to declare each parameter in my parameter list. e.g.
[HttpGet]
public async Task<ActionResult<IEnumerable<Customer>>> GetCustomers(int param1, string param2)
{
var queryString = HttpContext.Request.Query;
return await _context.Customers.Take(7).ToListAsync();
}
I want to avoid doing this because my class has several dozen parameters. I know that you can do binding with [FromQuery] Customer customer, but I don't think that's quite what I'm looking for.
Is there a way to do this dynamically?
[FromQuery] Dictionary<string, string>?