I've build an Asp.Net Core Controller and I would like to pass Data throw the Url to my Backend.
Throw my URI I would like to paste: filter:"[[{"field":"firstName","operator":"eq","value":"Jan"}]]
So my URI looks like: https://localhost:5001/Patient?filter=%5B%5B%7B%22field%22%3A%22firstName%22,%22operator%22%3A%22eq%22,%22value%22%3A%22Jan%22%7D%5D%5D
and my Controller:
[HttpGet]
public ActionResult<bool> Get(
[FromQuery] List<List<FilterObject>> filter = null)
{
return true;
}
and my FilterObject looks like:
public class FilterObject
{
public string Field { get; set; }
public string Value { get; set; }
public FilterOperator Operator { get; set; } = FilterOperator.Eq;
}
The Problem now is that my Data from the URL is not deserialized in my filter Parameter.
Do anyone have an Idea? Thans for helping.
Best Regards
You can achieve the requirement by implementing a custom model binder, the following code snippet is for your reference.
Controller action
Test Result