AdFactum ObjectMapper .NET Blog

Official blog of the AdFactum ObjectMapper .NET

Attribute: [GeneralLink]

Posted by Gerhard Stephan on June 11th, 2007

The attribute [GeneralLink] is the opposite of the attribute [BindPropertyTo]. It binds a property to a general class with an unspecified type. Therefore the type name of the bind object will be stored in an additional column. The name of that type column is calculated by the column name of the bound property added with a "#TYP".

        /// <summary>

        /// Gets or sets the contacts.

        /// </summary>

        /// <value>The contacts.</value>

        [GeneralLink(typeof(Contact))]

        public IList Contacts

        {

            get { return contacts; }

            set { contacts = value; }

        }

All objects that are stored within that collection, must be derived of the class "Contact" or must be objects of that type.

        /// <summary>

        /// Gets or sets the person.

        /// </summary>

        /// <value>The person.</value>

        [GeneralLink(typeof(IPerson))]

        public IPerson Person

        {

            get { return person; }

            set { person = value; }

        }

 

All objects that are stored in property "Person", must implement the interface "IPerson".

        /// <summary>

        /// Gets or sets the contacts.

        /// </summary>

        /// <value>The contacts.</value>

        [GeneralLink]

        public IList Contacts

        {

            get { return contacts; }

            set { contacts = value; }

        }

 

        /// <summary>

        /// Gets or sets the person.

        /// </summary>

        /// <value>The person.</value>

        [GeneralLink]

        public IPerson Person

        {

            get { return person; }

            set { person = value; }

        }

Note: If no base class has been specified, "ValueObject" will be taken as the base type for the linked objects. Therefore all objects that will be stored within that collection must be derived from the class "ValueObject".

Additionally have a look at the blog entry "How to do bind collections"

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>