Skip to content

Retrieving a single row by key

object edited this page Feb 11, 2013 · 15 revisions

Every OData collection must define a key that consists of a single or multiple properties and can be used for entry lookup and addressing links between different OData collections.


Lookup a row by single numeric key

var product = client
    .From("Products")
    .Key(1);
Assert.Equal("Chai", product["ProductName"]);

Request URI: GET Products(1)


Lookup a row by single string key

var customer = client
    .From("Customers")
    .Key("ALFKI");
Assert.Equal("ALFKI", customer["CustomerID"]);

Request URI: GET Customers(%27ALFKI%27)


Lookup a row by compound key

var orderDetails = client
    .From("OrderDetails")
    .Get(10248, 11);
Assert.Equal(10248, orderDetails["OrderID"]);

Request URI: GET OrderDetails(OrderID%3d1%2cProductID%3d1)


See also:
Retrieving data