Attribute: [InsertFunction]
Posted by Gerhard Stephan on March 21st, 2007
The InsertFunction attribute is used to define a database function that is called when inserting the object into the database. This function might be used to store the creation date of an object to database. Have a look at the following example.
/// <summary>
/// Gets or sets the creation.
/// </summary>
/// <value>The creation.</value>
[InsertFunction("GETDATE()")]
public DateTime Creation
{
get { return creation; }
set { creation = value; }
}
The created SQL looks like:
INSERT INTO [DATABASEFUNCTION] ( [CREATION], [ID]) VALUES ( GETDATE(), ‘12fca955-12ba-4486-bf89-4bf92d6db13d’);
