forked from simplefx/Simple.OData
-
Notifications
You must be signed in to change notification settings - Fork 200
Retrieving a single row by key
object edited this page Oct 4, 2012
·
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. Simple.Data method Get is used for key-based collection lookup.
Lookup a row by single numeric key:
OData URI: Products(1)
var product = _db.Products.Get(1); Assert.Equal("Chai", product.ProductName);
Lookup a row by single string key:
OData URI: Customers(%27ALFKI%27)
var customer = _db.Customers.Get("ALFKI"); Assert.Equal("ALFKI", customer.CustomerID);
Lookup a row by compound key:
OData URI: Order_Details(OrderID%3d1%2cProductID%3d1)
var orderDetails = _db.OrderDetails.Get(10248, 11); Assert.Equal(10248, orderDetails.OrderID);