forked from simplefx/Simple.OData
-
Notifications
You must be signed in to change notification settings - Fork 199
Using Any and All
Jason Finch edited this page Aug 23, 2018
·
3 revisions
Simple.OData.Client supports Any and All functions that can be used to create powerful OData queries.
var flights = await client
.For("Person")
.Filter(any(Trips,Budget gt 10000m))
.FindEntriesAsync();
Assert.True(flights.All(x => x.Trips.Any(y => y.Budget > 10000d)));
var flights = await client
.For<Person>()
.Filter(x => x.Trips
.Any(y => y.Budget > 10000d))
.Expand(x => x.Trips)
.FindEntriesAsync();
Assert.True(flights.All(x => x.Trips.Any(y => y.Budget > 10000d)));
var x = ODataDynamic.Expression;
IEnumerable<dynamic> flights = await client
.For(x.Person)
.Filter(x.Trips
.Any(x.Budget > 10000d))
.Expand(x.Trips)
.FindEntriesAsync();
Assert.True(flights.All(x => x.Trips.Any(y => y.Budget > 10000d)));
Request URI: GET People?$filter=Trips%2Fany%28x1%3Ax1%2FBudget%20gt%2010000.0%29
var flights = await client
.For("Person")
.Filter(all(Trips,Budget gt 10000m))
.FindEntriesAsync();
Assert.True(flights.All(x => x.Trips.All(y => y.Budget > 10000d)));
var flights = await client
.For<Person>()
.Filter(x => x.Trips
.All(y => y.Budget > 10000d))
.Expand(x => x.Trips)
.FindEntriesAsync();
Assert.True(flights.All(x => x.Trips.All(y => y.Budget > 10000d)));
var x = ODataDynamic.Expression;
IEnumerable<dynamic> flights = await client
.For(x.Person)
.Filter(x.Trips
.All(x.Budget > 10000d))
.Expand(x.Trips)
.FindEntriesAsync();
Assert.True(flights.All(x => x.Trips.All(y => y.Budget > 10000d)));
Request URI: GET People?$filter=Trips%2Fall%28x1%3Ax1%2FBudget%20gt%2010000.0%29
See also:
Retrieving data
OData URI conventions