EntityEventArgs and EntityCancelEventArgs

These are our custom event argument classes, and one or the other is used in all of the events in EntityBase. EntityEventArgs is used in the Init, PropertyChanged, Saved, Updated, Inserted and Deleted events. It inherits from EventArgs, and adds on an Entity property, which will be the entity that the event is happening on. For Saved, Updated, Inserted and Deleted, it will also have the SqlHelper set on it, so that you can do work with the database and have it partipate in the current transaction. EntityCancelEventArgs inherits from CancelEventArgs, but adds on an Entity property and the current SqlHelper so you can participate in the current transaction. It is used in the Saving, Updating, Inserting, and Deleting events. By setting the Cancel property to true, you can prevent the pending operation from occuring:
public void Customer_Saving(object sender EntityCancelEventArgs e)
    e.Cancel = true;

This will prevent the pending save operation from happening, and will leave your entity in a dirty state.

Last edited Dec 31, 2007 at 3:48 PM by banderson, version 3


No comments yet.