HORK Sample: Finding data with HORK

There are multiple ways to find data with HORK.
The primary operation used to find data is to call the Load method in the loader class of a given entity.
For example, if we wanted to load an Order from the Downwind database we would use the OrderLoader loader class and call the LoadOrder() method:

// Load up an Order
// This is the uniqueidentifier value of the Order created in Sample 1
Guid orderId = "009AEF2C-EFC8-460E-8F34-7C0D24BD3CC4";

OrderLoader loader = new OrderLoader();
Order order = loader.LoadOrder(orderId);

Using the Load method is limited to loading an entity based on its primary key column. The column Orders.Id is the primary key and it is a uniqueidentifier.

When you need to search on one or more columns, you can use the Find method in the loader class of a given entity.
// Create a new instance to start.
// Every property change after this point will be
// used as criteria to find entities. 
Address address = new Address();

// This will find addresses that have the specific City, AND...
address.City = "Springfield";
// Find addresses that have the specified PostalCode
address.PostalCode = 54321;

// Let see if there are any Addresses which match the criteria:
Address[] addresses = new AddressLoader().FindAddress(address);