Radzen documentation and examples for versions lower than Net Core 6 and Odata 8.
The first problem is in the response I get from server, does not match in return type.
The second filters
Here is the service configuration:
public async Task<ODataServiceResult<PersonDto>> GetPeopleAsync(string filter = default(string), int? top = default(int?), int? skip = default(int?), string orderby = default(string), string expand = default(string), string select = default(string), bool? count = default(bool?))
{
var uri = new Uri(http.BaseAddress, $"api/Persons");
uri = uri.GetODataUri(filter: filter, top: top, skip: skip, orderby: orderby, expand: expand, select: select, count: count);
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri);
var response = await http.SendAsync(httpRequestMessage);
return await response.ReadAsync<ODataServiceResult<PersonDto>>();
}
Here is the controller configuration:
[EnableQuery(MaxExpansionDepth = 10, MaxNodeCount = 1000)]
[HttpGet]
public IEnumerable<PersonDto> Get()
{
var people = context.Persons.ConvertToDto().AsQueryable();
return people;
}
Good if write query
https://localhost:7069/api/Persons?$top=5&$skip=0&$count=true
in browser it works I get results(5) as expected.
But for filters with query
https://localhost:7069/api/Persons?$filter=(LastName+%3d%3d+null+%3f+%27%27+%3a+LastName).ToLower().Contains(%27s%27.ToLower())&$top=5&$skip=0&$count=true
I got this error :
{"Message":"The query specified in the URI is not valid. ')' or operator expected at position 10 in '(LastName == null ? '' : LastName).ToLower().Contains('d'.ToLower ())'.","ExceptionMessage":"')'