Retrieving a single row matching search criteria specified in a method name

object edited this page Oct 9, 2012 · 6 revisions

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


Find a products with the given name

var product = _db.Products.FindAllByProductName("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.FindByCategoryIDAndSupplierID(1,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 FindBy