forked from simplefx/Simple.OData
-
Notifications
You must be signed in to change notification settings - Fork 200
Retrieving all data from a collection
object edited this page Oct 4, 2012
·
28 revisions
Simple.Data method All is used to retrieve all data from a collection.
Retrieve all products:
OData URI: Products
IEnumerable<dynamic> products = _db.Products.All(); Assert.NotEmpty(products);
Retrieve all order details using different naming convention for OrderDetails collection:
OData URI: OrderDetails
IEnumerable<dynamic> orderDetails = _db.Order_Details.All(); Assert.NotEmpty(orderDetails);
Retrieve product total count:
OData URI: Products/$count
var count = _db.Products.All().Count(); Assert.True(count > 0);
Retrieve all products with total count and take the first row in a single operation:
OData URI: Products?$top=1&$inlinecount=allpages
Promise<int> count; IEnumerable<dynamic> products = _db.Products.All().WithTotalCount(out count).Take(1); Assert.NotEmpty(products); Assert.True(count > 1);
See also:
Simple.Data documentation for All