Events

You can attach event handlers for the following events:

Event Description
ObjectCreating Before an object is inserted in the database
ObjectCreated After an object is inserted in the database
ObjectSaving Before an object is updated in the database
ObjectSaved After an object is updated in the database
ObjectDeleting Before an object is deleted from the database
ObjectDeleted After an object is deleted from the database

The "before" events can be cancelled by setting the Cancel property of the event arguments to true.

Events are attached to the DataSet's Events property:

var dbCustomers = dbContext.DataSet<Customer>();

dbCustomers.Events.ObjectCreating += (sender,args) => {
   Console.WriteLine("Creating customer {0}", args.Value.Name);

   args.Cancel = true; // if you want to cancel the insert operation
}

The event arguments always have a property Value which points to the object being inserted/updated/deleted. For "before" events, there's also a boolean Cancel property which can be set to true if the operation should not be executed.