I couldn't find much about this in the documentation, all of the examples has primitive types in their input, like int id.
I did find an example though of someone passing a Date, and i was thinking that maybe the controller knows how to parse a UNIX timestamp?
and i tried the following:
[HttpGet]
public async Task<IActionResult> Get([FromQuery] IEnumerable<int> ids)
{
IEnumerable<User> userIds = await _userRepository.FindByAsync(user => ids.Contains(user.Id), "");
if (userIds == null) return NotFound();
IEnumerable<UserDto> userDtos = players.Select(Mapper.Map<UserDto>);
return Json(userDtos);
}
But i got invalid modelState when i tried to call it with /api/users/get?ids=1,2,4,5,6
So it doesn't know how to parse a IEnumerable? so i have a few concrete questions:
- Should i just take in a collection as a string, split on the ',' and cast it to ints? should i create some middleware that does this validation/transformation before it even hits the controller or?
2.How does someone put in a Date field in the controller? is it documented anywhere what complex types is supported? Or did the persons example code i saw do something extra behind the scenes?