Knight Data Access Layer
Deleting Records
Basic Tasks C# > Deleting Data > Deleting Records

Explicitly delete records by calling the Delete method.  There are methods to delete by object, by primary key, by passed parameters.  To do a delete of the object with the children, see Deleting with Children.

 

//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);

 

//Delete the record in the database

db.Delete(currentPerson);