I'm trying to get my simple ASP.NET Core 7 minimal API to automatically bind the QueryString parameters into a single POCO.
For example:
https://localhost:5000/some/endpoint?a=1&b=hello&c=true
public record Query(int? A, string? B, bool? C); // Notice how all are optional!
public static async Task<Ok<List<Result>>> HandleAsync(
Query query,
MyDbContext myDbContext,
HttpContext context,
CancellationToken cancellationToken
)
{ .. }
If I do that, the framework is thinking/expecting the Query item to be [FromBody]. I've also tried this
[FromQuery] Query query,
but that also didn't work. (Unless I did something wrong).
Of course, this would work:
public static async Task<Ok<List<Result>>> HandleAsync(
int? a,
string? b,
bool? c,
MyDbContext myDbContext,
HttpContext context,
CancellationToken cancellationToken
)
but I don't want/like that. What can I try next?