The ObjectMapper .NET Project

Official blog of the AdFactum ObjectMapper .NET

Archive for June, 2007

Attribute: [GeneralLink]

Posted by Gerhard Stephan on 11th June 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"

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Posted in Attributes | No Comments »

Attribute: [PrimaryKey]

Posted by Gerhard Stephan on 11th June 2007

The property PrimaryKey can be used to tag a property that acts as a primary key column for the mapped table. In our classes ValueObject and AutoIncValueObject the Id Property has this attribute already assigned. Therefore this is only important if you write your own base classes or you define interfaces that shall be mapped.

    /// <summary>

    /// Interface that describes a person

    /// </summary>

    public interface IPerson : IValueObject

    {

        /// <summary>

        /// Gets or sets the unique value object id.

        /// </summary>

        /// <value>The unique value object id.</value>

        [PrimaryKey]

        new int? Id

        {

            get;

            set;

        }

 

 

Note: Combined primary keys are not allowed using the AdFactum ObjectMapper .NET.

Hint: It’s also valid to tag the primary key property with additional attributes, like [PropertyName] or [PropertyLength] to change the database binding.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Posted in Attributes | 1 Comment »

New Release – AdFactum ObjectMapper .NET 1.70.1706.0

Posted by Gerhard Stephan on 11th June 2007

Today I’m proud to present the next version of the AdFactum ObjectMapper .NET. This release covers one primary feature. The AdFactum ObjectMapper .NET is now able to handle primary keys other than GUIDs. That means it can handle autoincremented ident numbers for Oracle, Microsoft SQL Server and Microsoft Access. Therefore two new base classes have been established.

AutoIncValueObject:

This base class offers an autoincremented ident number as the primary key for every table. When using Oracle, all necessary sequences and triggers will be generated automatically.

GenericValueObject<T>:

This generic value object base class can handle all property types that can be mapped by the AdFactum ObjectMapper .NET and uses the given type as the primary key for the value object.

Interface Changes, IValueObject:

But you can also implement your own base class by using the IValueObject interface. If you do so, you have to specify the property that will be taken as the primary key for the table. Therefore you have to tag your primary key property with the [PrimaryKey] Attribute.

Interface Changes, IObjectFactory:

In order to gain a bit more performance the IObjectFactory interface has been extended. You now have to implement a new function Type GetType(string) which returns a Type object from a parameter typename given as string.

Attribut Changes, GenericLink:

Now the GenericLink attribute needs a base class to determinate the type of the primary key used by all derived classes that will be linked with the property. If no base class for the GenericLink attribute has been specified, the class ValueObject will be taken as the base class.

Attribut Changes, BackLink:

The BackLink attribute needs one new paramenter called "CurrentClass" in order to specify the primary key of the entity type.

That are the biggest changes. As a second new feature I added a new solution file that can be used by the Microsoft Visual Studio Orcas Beta 1 Release.

So that’s all for now.
Wish you all a very nice week.

Cheers

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Posted in Releases | No Comments »