Creating endpoints for every query is no fun. This repo demonstrates how you can implement dynamic querying using LINQ to filter, sort and expand when fetching REST resources.
- Run the API
dotnet run --project DynamicQuery.WebApi
- Query the endpoint with your favorite http client (curl examples below):
# filtering
curl --get "http://localhost:5240/orders" --data-urlencode 'filter=type == "D1"'
curl --get "http://localhost:5240/orders" --data-urlencode 'filter=type.Contains("D") && id != 2'
# sorting
curl --get "http://localhost:5240/orders" --data-urlencode 'order=id desc'
curl --get "http://localhost:5240/orders" --data-urlencode 'order=customer.id, id desc'
# expanding child entities
curl --get "http://localhost:5240/orders" --data-urlencode 'expand=Customer,Lines'