“Horking

 

HORK Sample: Changing data with HORK

Changing data in an ORM mean loading some existing data and changing one or more properties, with the intent that the same columns will be updated in the database.
This is how you change data in HORK:

// Load up an Order
ContactLoader loader = new ContactLoader();
Contact contact = loader.LoadContact(contactId);
Console.WriteLine("Contact was loaded: " + contact.ContactId);

// Change order properties.
// Once the Contact entity is loaded, any property changes are
// considered criteria for what columns to update.
contact.FirstName = firstName;
contact.MobilePhone = phoneNumber;  

// Update order.
// Since we only set the FirstName and MobilePhone properties,
// this is the same as this SQL:
// UPDATE Contacts SET FirstName = 'firstName' AND MobilePhone = 'phoneNumber' 
// WHERE Id = contact.ContactId
bool updated = contact.Update();

if (updated)
{
    Console.WriteLine("Contact was updated without error.");
}
else
{
    Console.WriteLine("Contact update failed.");
}