Skip to content

Retrieving all data from a collection

object edited this page Oct 4, 2012 · 28 revisions

All is used to retrieve all data from a collection.

Retrieve all products: IEnumerable products = _db.Products.All(); Assert.NotEmpty(products);

Retrieve all order details using different naming convention for OrderDetails collection: IEnumerable orderDetails = _db.Order_Details.All(); Assert.NotEmpty(orderDetails);

Retrieve product total count: var count = _db.Products.All().Count(); Assert.True(count > 0);

Retrieve all products with total count in a single operation Promise count; IEnumerable products = _db.Products.All().WithTotalCount(out count).Take(1); Assert.NotEmpty(products); Assert.True(count > 1);


See also:
Simple.Data documentation for All