Retrieving a single row matching search criteria

object edited this page Oct 9, 2012 · 6 revisions

Simple.Data method Find is used to retrieve all data that satisfy search criteria.


Find a product with the given name

var product = _db.Products.Find(_db.Products.ProductName == "Chai");
Assert.Equal("Chai", product.ProductName);

Request URI: GET Products?$filter=ProductName+eq+%27Chai%27


Find a product with the given category and supplier

var product = _db.Products.Find(_db.Products.CategoryID == 1 && _db.Products.SupplierID == 1);
Assert.Equal("Chai", product.ProductName);

Request URI: GET Products?$filter=CategoryID+eq+1+and+SupplierID+eq+1


See also:
Retrieving data
Simple.Data documentation for Find