forked from simplefx/Simple.OData
Retrieving all data from a collection
ejbiker93ss edited this page May 11, 2023
·
28 revisions
Retrieve all products
Untyped syntax
var products = await _client
.For("Products")
.FindEntriesAsync();
Assert.NotEmpty(products);Typed syntax
var products = await _client
.For<Products>()
.FindEntriesAsync();
Assert.NotEmpty(products);Dynamic syntax
var x = ODataDynamic.Expression;
var products = await _client
.For(x => x.Products)
.FindEntriesAsync();
Assert.NotEmpty(products);Request URI: GET Products
Retrieve product total count
Untyped syntax
var count = await _client
.For("Products")
.Count()
.FindScalarAsync();
Assert.True(count > 0);Typed syntax
var count = await _client
.For<Products>()
.Count()
.FindScalarAsync<int>();
Assert.True(count > 0);Dynamic syntax
var x = ODataDynamic.Expression;
var count = await _client
.For(x => x.Products)
.Count()
.FindScalarAsync();
Assert.True(count > 0);Request URI: GET Products/$count
Retrieve all products with total count and take the first row in a single operation
Untyped syntax
Promise<int> count;
var products = await _client
.For("Products")
.FindEntriesAsync(true, out count);
Assert.NotEmpty(products);
Assert.True(count > 1);Typed syntax
Promise<int> count;
var products = await _client
.For<Products>()
.FindEntriesAsync(true, out count);
Assert.NotEmpty(products);
Assert.True(count > 1);Dynamic syntax
Promise<int> count;
var x = ODataDynamic.Expression;
var products = await _client
.For(x => x.Products)
.FindEntriesAsync(true, out count);
Assert.NotEmpty(products);
Assert.True(count > 1);Request URI: GET Products?$top=1&$inlinecount=allpages
See also:
Retrieving data