The ObjectMapper .NET Project

Official blog of the AdFactum ObjectMapper .NET

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

 Votes | Average: 0 out of 5 Votes | Average: 0 out of 5 Votes | Average: 0 out of 5 Votes | Average: 0 out of 5 Votes | Average: 0 out of 5 (No Ratings Yet)
Loading ... Loading ...

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>