AdFactum ObjectMapper .NET Blog

Official blog of the AdFactum ObjectMapper .NET

Attribute: [Required]

Posted by Gerhard Stephan on September 7th, 2006

You can use the Required attribute to force that the property must be filled. Within the DDL creation process the ObjectMapper .NET adds a "NOT NULL" to the column definition.

This can be used to create mandatory fields that are checked by database. If you try to store an empty property that is marked as required, the database will throw an exception.

Here’s an example how to mark a property as required.

            [Required]

            public string LastName

            {

                  get { return _lastName; }

                  set { _lastName = value; }

            }

 

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>