forked from simplefx/Simple.OData
-
Notifications
You must be signed in to change notification settings - Fork 200
Results projection, paging and ordering
object edited this page Feb 12, 2013
·
13 revisions
Simple.OData.Client supports all stanard OData query modifiers that can be used to control number of rows and columns fetched during the request execution.
var products = client .For("Products") .Select("ProductID") .FindEntries(); Assert.True(products.First()["ProductID"] > 0); Assert.False(products.First().ContainsKey("ProductName"));
Request URI: GET Products?$select=ProductID
var products = client .For("Products") .Top(1) .FindEntries(); Assert.Equal(1, products.Count());
Request URI: GET Products?$top=1
var products = client .For("Products") .Skip(1) .FindEntries(); Assert.Equal(76, products.Count());
Request URI: GET Products?$skip=1
var products = client .For("Products") .Skip(2) .Top(1) .FindEntries(); Assert.Equal(1, products.Count());
Request URI: GET Products?$skip=2&$top=1
var products = client .For("Products") .OrderBy("ProductName") .FindEntries(); Assert.Equal("Alice Mutton", products.First()["ProductName"]);
Request URI: GET Products?$orderby=ProductName
var products = client .For("Products") .OrderByDescending("ProductName") .FindEntries(); Assert.Equal("Zaanse koeken", products.First()["ProductName"]);
Request URI: GET Products?$orderby=ProductName%20desc
var products = client .For("Products") .OrderByDescending("ProductName") .Select("ProductName") .FindEntries(); Assert.Equal("Zaanse koeken", products.First()["ProductName"]);
Request URI: GET Products?$orderby=ProductName%20desc&$select=ProductName
See also:
Retrieving data