Closed
Description
E.g. make something like this work:
app.MapPost("/widget", (CreateWidgetDTO dto) =>
{
// Use the dto
});
public abstract class DTO<T>
{
// typeof(T) must equal ParameterInfo.Type otherwise we throw
public static T BindAsync(HttpContext context, ParameterInfo parameter)
{
// Use reflection to bind the properties on T
}
}
public class CreateWidgetDTO : DTO<CreateWidgetDTO>
{
[FromRoute]
public string? Name { get; set; }
[FromQuery]
public int Id { get; set; }
}