Manipulate Data in the Cloud: ADO.NET Data Services Framework URI Query Options: Table 1: Apply Query Options to Shape and Page the Content Returned.
URI queries more complex than those to return a single Atom <entry>, property, or collection of <entry>s require use of one or more of the six query option reserved words: $expand, $filter, $orderby, $skip, $top, and $value. Use an ampersand (&) to separate multiple option expressions. The .../ abbreviation represents the service prefix, such as http://localhost:52660/Northwind.svc. Entity, EntitySet, and property names are case-sensitive. Italic text in the table is part of the URI query. The $metadata option, which returns the full set of metadata from the conceptual layer (*.CSDL file), isn't included in the table because it doesn't affect shaping or paging content. Browsers URL-encode spaces in URI queries as %20.
Option |
Description |
Example |
$expand |
Returns nested related entities with the target entity |
.../Customers('RATTC')?$expand=Orders returns a <feed> document with
Customer data and <entry>s for all Orders placed by the Customer.
.../Customers('RATTC')?$expand=Orders(10262)/Employee returns a <feed> document with header data and Order_Details <entry>s for Order 10262.
.../Orders(10262)?$expand=Shipper,Employee returns an <entry> fragment with Orders, Shipper, and Employee content. |
$filter |
Restricts the content returned by the operator expression (see Table 2) |
.../Orders?$filter=ShipCountry eq 'USA' returns all Orders shipped to the United States.
.../Orders?$filter=ShipCity eq 'USA' and OrderDate gt '1996-12-31' returns all Orders shipped to the United States after Dec. 31, 1996 (see Table 2).
|
$orderby |
Sorts the content by the specific property value ascending (asc, default) or descending (desc) |
.../Orders?$orderby=ShipCountry sorts alphabetically by destination country.
.../Orders?$orderby=ShipCountry desc reverses the sort order.
.../Orders?$orderby=ShipCountry desc,ShipCity adds destination city to the sort.
|
$skip |
Skips the number of instances specified by the skip parameter |
.../Orders?$skip=10 returns all Orders after the first 10. |
$top |
Supplies the number of instances specified by the top parameter |
.../Orders?$skip=10&$top=10 returns 10 Orders after the first 10.
.../Orders?$skip=90&$top=10 returns the tenth page with 10 Orders
per page.
|
$value |
Returns the scalar value of a property or resource |
.../Categories(1)/Description/$value gives you the string value of Description for a given category, not an ATOM entry. |
|