Skip to content

Retrieving all data from a collection

Vagif Abilov edited this page Nov 20, 2013 · 28 revisions

Retrieve all products

// Untyped syntax
var products = _client
    .For("Products")
    .FindEntries();
Assert.NotEmpty(products);

// Typed syntax
var products = _client
    .For<Products>()
    .FindEntries();

// Dynamic syntax
var x = ODataDynamic.Expression;
var products = _client
    .For(x => x.Products)
    .FindEntries();

Request URI: GET Products


Retrieve product total count

// Untyped syntax
var count = _client
    .For("Products")
    .Count()
    .FindScalar();
Assert.True(count > 0);

// Typed syntax
var count = _client
    .For&ltProducts&gt()
    .Count()
    .FindScalar();

// Dynamic syntax
var x = ODataDynamic.Expression;
var count = _client
    .For(x => x.Products)
    .Count()
    .FindScalar();

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 = _client
    .For("Products")
    .FindEntries(true, out count);
Assert.NotEmpty(products);
Assert.True(count > 1);

// Typed syntaxPromise<int> count;
var products = _client
    .For&ltProducts&gt()
    .FindEntries(true, out count);

// Dynamic syntax
Promise<int> count;
var products = _client
    .For(x => x.Products)
    .FindEntries(true, out count);

Request URI: GET Products?$top=1&$inlinecount=allpages


See also:
Retrieving data