taki kod działa poprawnie, binduje poprawnie
[HttpGet("get")]
public ActionResult<IEnumerable<Customer>> customers([FromQuery(Name = "id[]")] IEnumerable<int> id)
{
//taki leci get z frontu http://api/customer/get?id[]=388&id[]=211&id[]=189&id[]=252&id[]=359&id[]=153&id[]=270
}
natomiast
public ActionResult<IEnumerable<Order>> GetAll([FromQuery] SalesRepresentativeDateRangeRequest request) {}
public class SalesRepresentativeDateRangeRequest
{
public IEnumerable<int> SalesRepresentativeId { get; set; }
public DateTime Start { get; set; }
public DateTime End { get; set; }
}
// taki leci get z frontu http://api/order/all?SalesRepresentativeId[]=388&SalesRepresentativeId[]=211&SalesRepresentativeId[]=189&SalesRepresentativeId[]=252&SalesRepresentativeId[]=359&SalesRepresentativeId[]=153&SalesRepresentativeId[]=270&Start=2023-03-01&End=2023-03-31
SalesRepresentativeId
w ogóle nie jest zbindowany
jak poprawnie zbindować
get
jeśli to jest jedyny get w tym kontrolerze. Zmień na[HttpPost("customers")]
i zrób parametr[FromBody]
i nie przejmuj się "konwencjami" o ile korpo ci na to pozwala.