Skip to content

Easy way to dynamically query data on .NET web apis

License

Notifications You must be signed in to change notification settings

bm0niz/dynamic-webapi-query

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dynamic Querying WebAPIs

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.

  1. Run the API
dotnet run --project DynamicQuery.WebApi
  1. 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'

About

Easy way to dynamically query data on .NET web apis

Resources

License

Stars

Watchers

Forks

Languages