Retrieving all data from a collection

object edited this page Oct 9, 2012 · 15 revisions

Simple.Data method All is used to retrieve all data from a collection.

Retrieve all products

IEnumerable<dynamic> products = _db.Products.All();

Request URI: GET Products

Retrieve all order details using different naming convention for OrderDetails collection

IEnumerable<dynamic> orderDetails = _db.Order_Details.All();

Request URI: GET OrderDetails

Retrieve product total count

var count = _db.Products.All().Count();
Assert.True(count > 0);

Request URI: GET Products/$count

Retrieve all products with total count and take the first row in a single operation

Promise<int> count;
IEnumerable<dynamic> products = _db.Products.All().WithTotalCount(out count).Take(1);
Assert.True(count > 1);

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

See also:
Retrieving data
Simple.Data documentation for All