abdusco / queree

Dynamic OData-like filters for ASP.NET APIs without using OData library. (WIP)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Queree

Dynamic filtering extensions for IQueryable that allows API clients to specify OData $filter , $orderby, $skip, $top query string filter parameters without bringing the whole OData library to the mix.

[HttpGet]
public IActionResult Index(Query query)
{
    return Ok(_dbContext.Users.ApplyQuery(query).ToList());
}

Example

Giving "?$skip=1&$top=2&$filter=startswith(Name, 'j') or year(birthdate) ge 1970&$orderby=id desc" will filter a list of actors down to this subset:

[
  {
    "id": 7,
    "name": "Charlize Theron",
    "birthDate": "1986-01-01T00:00:00"
  },
  {
    "id": 6,
    "name": "Jennifer Lawrence",
    "birthDate": "1975-01-01T00:00:00"
  }
]

Limitations

  • $orderby parameter does not support multiple orders (first name, then date etc.). At the moment only a single ordering is possible.

Thanks

This library is created thanks to a great guide by Evgeny Bychkov and StringToExpression library

About

Dynamic OData-like filters for ASP.NET APIs without using OData library. (WIP)


Languages

Language:C# 100.0%