AdFactum ObjectMapper .NET Blog

Official blog of the AdFactum ObjectMapper .NET

Archive for July, 2006

Attribute: [Table]

Posted by Gerhard Stephan on 13th July 2006

The table attribute is used to rename the mapping from class to database table.

      [Table („CONTACTS“)]

      public class Contact : ValueObject


The ObjectMapper .NET does not need that property to map the class to a database table. If the attribute misses, the class name itself will be taken as the valid name for the database table.

But most times it makes sense to rename the mapping of the class to the underlaying database table. Imagine your class is named "Contact", so you would instinctively name your database table "Contacts". That is because the database table contains the plural of your entities, but the class itself is defined as a singular entity.


Posted in Attributes | No Comments »

Attribute: [PropertyLength]

Posted by Gerhard Stephan on 11th July 2006

The PropertyLength attribute is used to specify the length of a database column.

Setting this attribute has no effect on how the ObjectMapper .NET will handle this property, but it defines the length of a database column and therefore it affects the DDL creation.

Look at this example:


            public string FirstName


                  get { return _firstName; }

                  set { _firstName = value; }



Furthermore it has an effect on which data type the database column will have. Dependent on the database system you’re using, strings can only be stored up to a specific length of e.g. Oracle 4000 characters. If you want to store longer strings you have to choose other data types that can handle unlimited string size, e.g. CLOBS in Oracle or MEMO fields for Micorosoft Access.

To force the ObjectMapper .NET to use such data types, you have to set the attribute PropertyLength to int.MaxValue.


            public string Text


                  get { return text; }

                  set { text = value; }



This example will force the ObjectMapper .NET to use data types like CLOB (Oracle), MEMO (Microsoft Access) or TEXT (Microsoft SQL Server).


Posted in Attributes | 1 Comment »

Attribute: [PropertyName]

Posted by Gerhard Stephan on 11th July 2006

The attribute PropertyName is used to specify the column name of the database table.

This attribute is NOT necessary to store a property in database, but it is necessary if you want to specify a column name that is independent from the name of the property. That’s maybe the case if you want to map your class to an already existing database table.


            public string CultureKey


                  get { return _culture; }

                  set { _culture = value; }



 The example above stores the property "CultureKey" in a column named "Culture".

Posted in Attributes | No Comments »

Attribute: [Ignore]

Posted by Gerhard Stephan on 7th July 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.


            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.

Posted in Attributes | No Comments »

New Release – ObjectMapper .NET 1.1.605.1

Posted by Gerhard Stephan on 5th July 2006

This release comes up with a lot of smaller changes and some new features.

Beginning with the new features I added a ListAdapter for dotNET 2.0 for a better support of generics. If you query the database with the ObjectMapper .NET you will receive a IList interface as the return value. The new dotNet 2.0 Framework offers no constructor that can handle this native IList interface in order to copy a untyped collection into a typed collection. Using the new ListAdapter a native IList can be converted to a IList<T> class.

            IList myNativeList = mapper.Select(typeof(Contact), null);


            IList<Contact> genericList = new List<Contact>(

                new ListAdapter<Contact>(myNativeList)


Furthermore the ObjectMapper .NET has now build in support for a better paging algorithm using the ranking functions of the SQL Server 2005. Thus enables the ObjectMapper .NET to implement a server side paging without loosing performance by seeking the result collection. The paging SQL might look like:


      SELECT      CONTACT.* ,





As a third thing I changed the QueryOperator.Like_NoCaseSensitive for the SQL Persister. The old version used TRIM to cut the spacings of the parameter. But this method is unkown to the SQL Server. The new version uses RTRIM which does almost the same.

Last but not least I changed some places where the ToString() method was unnecessarily used and replaced that ToString() method with a strong cast due to improve the performance.

Hope you enjoy the improvements.

Posted in Releases | No Comments »