forked from simplefx/Simple.OData
-
Notifications
You must be signed in to change notification settings - Fork 192
Retrieving data matching search criteria
Ian Thomas edited this page Nov 17, 2017
·
9 revisions
Untyped syntax
var products = await _client .For("Products") .Filter("CategoryID+eq+1") .FindEntriesAsync(); Assert.NotEmpty(products);
Typed syntax
var products = await _client .For<Products>() .Filter(x => x.CategoryID == 1) .FindEntriesAsync(); Assert.NotEmpty(products);
Dynamic syntax
var x = ODataDynamic.Expression; var products = await _client .For(x.Products)) .Filter(x.CategoryID == 1) .FindEntriesAsync(); Assert.NotEmpty(products);
Request URI: GET Products?$filter=CategoryID+eq+1
Untyped syntax
var products = await _client .For("Products") .Filter("length(ProductName)+eq+4") .FindEntriesAsync(); Assert.NotEmpty(products);
Typed syntax
var products = await _client .For<Products>() .Filter(x => x.ProductName.Length() == 4) .FindEntriesAsync(); Assert.NotEmpty(products);
Dynamic syntax
var x = ODataFilter.Expression; var products = await _client .For(x.Products) .Filter(x.ProductName.Length() == 4) .FindEntriesAsync(); Assert.NotEmpty(products);
Request URI: GET Products?$filter=length(ProductName)+eq+4
Untyped syntax
var x = ODataFilter.Expression; var count = await _client .For("Products") .Filter("ProductName+eq+%27Chai%27") .Count() .FindScalarAsync(); Assert.Equal(1, count);
Typed syntax
var count = await _client .For<Products>() .Filter(x => x.ProductName == "Chai") .Count() .FindScalarAsync(); Assert.Equal(1, count);
Dynamic syntax
var x = ODataFilter.Expression; var count = await _client .For(x.Products) .Filter(x.ProductName == "Chai") .Count() .FindScalarAsync(); Assert.Equal(1, count);
Request URI: GET Products/$count?$filter=ProductName+eq+%27Chai%27
Untyped syntax
Promise<int> count; var products = await _client .For("Products") .Filter("ProductName+eq+%27Chai%27") .FindEntriesAsync(true, out count); Assert.NotEmpty(products); Assert.Equal(1, count);
Typed syntax
var annotations = new ODataFeedAnnotations(); var products = await _client .For<Products>() .Filter(x => x.ProductName == "Chai") .FindEntriesAsync(annotations); Assert.NotEmpty(products); Assert.Equal(1, annotations.Count);
Dynamic syntax
Promise<int> count; var x = ODataFilter.Expression; var products = await _client .For(x.Products) .Filter(x.ProductName == "Chai") .FindEntriesAsync(true, out count); Assert.NotEmpty(products); Assert.Equal(1, count);
Request URI: GET Products?$filter=ProductName+eq+%27Chai%27&$inlinecount=allpages
See also:
Retrieving data