Knight Data Access Layer
Updating Records
Basic Tasks C# > Saving Data > Updating Records

Normally the Save Method is used to perform updates.  To perform an explicit update, see the example below.

//Get the current instance of the helper

IDataHelper db = DataHelper.SessionFactory();

 

//Create a new Person to save to the database

Person currentPerson = new Person();

currentPerson.FirstName = "John";

currentPerson.LastName = "Smith";

 

//Save it to the database

db.Save(currentPerson);

 

//Change a property

currentPerson.FirstName = "Jane";

 

//Save the change

db.Update<Person>(currentPerson);