forked from simplefx/Simple.OData
-
Notifications
You must be signed in to change notification settings - Fork 192
Retrieving data matching search criteria
Jason Finch edited this page Aug 23, 2018
·
9 revisions
var products = await _client
.For("Products")
.Filter("CategoryID+eq+1")
.FindEntriesAsync();
Assert.NotEmpty(products);
var products = await _client
.For<Products>()
.Filter(x => x.CategoryID == 1)
.FindEntriesAsync();
Assert.NotEmpty(products);
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
var products = await _client
.For("Products")
.Filter("length(ProductName)+eq+4")
.FindEntriesAsync();
Assert.NotEmpty(products);
var products = await _client
.For<Products>()
.Filter(x => x.ProductName.Length() == 4)
.FindEntriesAsync();
Assert.NotEmpty(products);
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
var x = ODataFilter.Expression;
var count = await _client
.For("Products")
.Filter("ProductName+eq+%27Chai%27")
.Count()
.FindScalarAsync();
Assert.Equal(1, count);
var count = await _client
.For<Products>()
.Filter(x => x.ProductName == "Chai")
.Count()
.FindScalarAsync();
Assert.Equal(1, count);
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
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);
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);
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