AdFactum ObjectMapper .NET Blog

Official blog of the AdFactum ObjectMapper .NET

Attribute: [Ignore]

Posted by Gerhard Stephan on July 7th, 2006

You can use the Ignore attribute to prevent the ObjectMapper .NET from mapping the property to database. This feature can be used for several use cases:

  • Calculated properties.
  • Properties that are only used by the UI.
  • Properties that are used to convert mapped properties to other data types.
  • etc.

Here’s an example for such a calculated property.

            [Ignore]

            public TimeSpan Duration

            {

                  get { return LogOffTime – LogOnTime; }

            }

           

            public DateTime LogOnTime

            {

                  get { return logOnTime; }

                  set { logOnTime = value; }

            }

 

            public DateTime LogOffTime

            {

                  get { return logOffTime; }

                  set { logOffTime = value; }

            }

 

In this example the LogOnTime and LogOffTime property will be stored in database. The duration will be calculated when accessing the property itself.

Leave a Reply

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