AdFactum ObjectMapper .NET Blog

Official blog of the AdFactum ObjectMapper .NET

Archive for the 'Releases' Category

New Release – AdFactum ObjectMapper .NET 2.0.2129.0

Posted by Gerhard Stephan on 30th October 2007

Today I’m proud to release version 2.0 of the AdFactum ObjectMapper .NET. This major release covers new key features like a first LINQ implementation, new projection classes and several bug fixes regarding the XML persister.

First of all, the ObjectMapper .NET does now understand the basic LINQ syntax. Please keep in mind that this is a first implementation and that it does not cover the complete functionality of LINQ. But it’s a first step. Be sure that the next release of the ObjectMapper .NET will cover a lot more LINQ features than it does today.

Linq Support

var orders = mapper.Query<Order>();

var customers = mapper.Query<Customer>();


var mexicanOrders =

from order in orders

join customer in customers on order.Customer equals customer

where customer.Country == "Mexico"

select order;


You’ll find several LINQ examples within the NUnit Test Cases.  

Anonymous Types

Because the dotNet Framework 3.0 does now support anonymous types, the AdFactum ObjectMapper .NET had to support these types in order to be LINQ conform.  Have a look at the following LINQ query.

var mexicanOrders =
      from order in orders
      join customer in customers on order.Customer equals customer
      where customer.Country == "Mexico"
select new {
                  order.ShipName };


The result of this query is a list with objects of an anonymous type. The anonymous type has four properties (CompanyName, ContactName, OrderDate and ShipName).

Projection class

The support of anonymous types leads to a new feature of the AdFactum ObjectMapper .NET. It was a absolute necessity to add an equal feature to the non LINQ version. That new feature has been called projection classes. A projection class is a class where the properties are used to mirror the results of multiple sources into one projection. 

     /// <summary>
    /// Class used for projections
    /// A class that is used for projects must not be a ValueObject!
    /// </summary>

    public class OrderCustomer
        private string companyName;
        private string contactName;
        private string shipName;

        /// <summary>
        /// Gets or sets the company name.
        /// </summary>
        /// <value>The company name.</value>
        [ProjectOntoProperty(typeof(Customer), "CompanyName")]
        public int CompanyName
            get { return companyName; }
            set { companyName = value;  }

        /// <summary>
        /// Gets or sets the contact name.
        /// </summary>
        /// <value>The contact name.</value>
        [ProjectOntoProperty(typeof(Customer), "ContactName")]
        public string ContactName
            get { return contactName; }
            set { contactName = value; }

        /// <summary>
        /// Gets or sets the ship name.
        /// </summary>
        /// <value>The name of the ship.</value>
        [ProjectOntoProperty(typeof(Order), "ShipName")]
        public string ShipName
            get { return shipName; }
            set { shipName = value; }


List<OrderCustomer> names = new List<OrderCustomer>(
      new ListAdapter<OrderCustomer>(
            mapper.Select(typeof (OrderCustomer),
            new Join(typeof (Order), “Customer”, typeof (Customer))));


Support of .NET 2003 closed

Because of all these new features and changes it wasn’t possible to keep the .NET 2003 support for the AdFactum ObjectMapper .NET. I hope that not many users are still working with .NET 2003, but there had not been an other solution. Due to this change, it’s necessary to de-install the ObjectMapper .NET first, before installing the new version. 

XML Persister

The Xml Persister has been greatly reworked. It’s now again possible to store object trees into an XML File. I say "again", because this features has been broken in one of the last versions of the AdFactum ObjectMapper .NET.  

Minor Bug Fixes

Last but not least, there have been many minor bug fixes.

  1. There were failures when defining primary keys other than already defined in the base classes, like ValueObject or AutoIncValueObject.
  2. The Access Persister did not throw the correct error number the time a failure occured. This forced the AccessPersister to execute the SQL multiple times before throwing an exception.
  3. Furthermore I implemented a new caching strategy which reduced the amount of cache access significantly.

And a lot of more minor bug fixes / changes that are not counted.

Hope you enjoy the new version.

– Gerhard 

kick it on

Posted in Releases | No Comments »

New Release – AdFactum ObjectMapper .NET 1.90.1917.0

Posted by Gerhard Stephan on 17th September 2007

The new release of the AdFactum ObjectMapper .NET covers several enhancements that have been discussed in other thread within this blog.

First of all the OBM (ObjectMapper .NET Manager Class) has been included in the current release. That means that you don’t have to implement multi threading functionality by your own. You can simple use the OBM helper class. The original idea of the OBM has been explained in Tutorial 4. The only difference is, that the signature of the Method CreateMapper has been changed.

public static ObjectMapper CreateMapper(DatabaseConnection connection)

The DatabaseConnection Property specifies the Database to that the ObjectMapper .NET connects to. I’m going to write further blog entries in order to explain the new OBM class.

Furthermore I replaced the class BaseFactory with the new UniversalFactory. This class covers the the changes from the blog entry "A Final performance boost" which unleash incredible performance when loading many objects. To enable this performance boost your entities have to implement the ICreateObject interface.

    public interface ICreateObject


        /// <summary>

        /// Creates the new object.

        /// </summary>

        /// <returns></returns>

        IValueObject CreateNewObject();



As third improvement I re-worked all classes that implements the IDisposable interface in order to use the correct IDisposable Pattern.

Last but not least, I fixed the bug "[ 1793851 ] OrderBy does not generate parenthesis". The problem was that SQL Statements misses parenthesis within the ORDER BY clause. Which is very bad if you are using reserved words like INDEX.

That’s all for now.

– Gerhard

Posted in Releases | No Comments »

New Release – AdFactum ObjectMapper .NET 1.81.1917.0

Posted by Gerhard Stephan on 17th August 2007

This release solves a bug that occured sometimes when saving aggregated objects which are bound by the [GeneralLink] attribute. The ObjectMapper .NET crashed with a NullReferenceException. That bug has now been fixed.

Wish you a nice weekend


Posted in Releases | No Comments »

New Release – AdFactum ObjectMapper .NET 1.80.1811.0

Posted by Gerhard Stephan on 11th July 2007

It’s time again to present a new release. As suggested in trouble ticket the AdFactum ObjectMapper .NET does now support the attribute [DefaultValue]  to create DDL scripts that includes the specified default value.

As a second thing, a bug within the repository has been fixed. It occured when trying write the repository. If a table name with two or less characters exists, the AdFactum ObjectMapper .NET ended with an exception.

As a Last point, the update mechanism of character properties has been fixed. In prior versions character properties were all time being updated, although no data change has occured.

That’s all for now


Posted in Releases | No Comments »

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.


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.


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.


Posted in Releases | No Comments »

New Release – AdFactum ObjectMapper .NET 1.62.1602.0

Posted by Gerhard Stephan on 2nd May 2007

The new version of the AdFactum ObjectMapper .NET covers two bugs and one enhancement.

First of all, the Microsoft SQL Server Compact Edition (CE) can now be used with Desktop Applications. Therefore the SqlCEPersister has been added to ObjectMapper .NET solution.

Regarding this functionality I fixed two bugs that have been announced in SourceForge. The first bug (a critical one) prevented storing objects that had duplicated values and property types. The second bug produced a wrong update DDL Script when using the [GeneralLink] attribute on aggregated properties. This bug not only appeared when using SqlCEPersister.

Both bugs (and some smaller bugs too) have been fixed for the current version.

Hope you enjoy the new version


Use the following link to download the new version: 

Posted in Releases | No Comments »

New Release – ObjectMapper .NET 1.60.1517.1

Posted by Gerhard Stephan on 17th April 2007

Today I’m proud to present the new major release of the AdFactum ObjectMapper .NET.  This release includes two new features and one major attribute change.

As a new feature I extended the join condition in order to enable joining objects with objects, types with objects and types with types. Thus reduces the amount of conditions that are necessary to limit the database query.

Imagine we have a structure like that:

            Employee emp = new Employee("All", "Mine");

            FullFeaturedCompany c1 = new FullFeaturedCompany("Heavy stuff");

            c1.Owner = emp;

            FullFeaturedCompany c2 = new FullFeaturedCompany("Light stuff");

            c2.Owner = emp;


            Employee emp2 = new Employee("Thats", "not mine");

            FullFeaturedCompany c3 = new FullFeaturedCompany("Other stuff");

            c3.Owner = emp2;


Now you have several possibilities to join these Company -> Employee structure.



             * Join company c1 object with owner object


            FullFeaturedCompany loaded;

            loaded = (FullFeaturedCompany) Mapper.FlatLoad(typeof (FullFeaturedCompany),

                new Join(c1, "Owner", emp));

            Assert.AreEqual(c1.Id, loaded.Id, "Could not load company");



             * Join typeof(Company) with owner object


            IList selection;

            selection = Mapper.FlatSelect(typeof (FullFeaturedCompany),

                new Join(typeof (FullFeaturedCompany), "Owner", emp));

            Assert.AreEqual(2, selection.Count, "Could not find the 2 expected companies.");



             * Join typeof(Company) with typeof(Employee)


            selection = Mapper.FlatSelect(typeof(FullFeaturedCompany),

                new Join(typeof(FullFeaturedCompany), "Owner", typeof(Employee)));

            Assert.AreEqual(3, selection.Count, "Could not find the 3 expected companies.");



As a second new feature I extended the InCondition. In prior versions the InCondition could only use SubSelects or Unions to build IN Condition SQL statements. Now it’s possible to give value arrays or value lists to the ObjectMapper .NET in order to support queries like "field IN (value1, value2, … valueN)".



             * Insert some test contacts



            Mapper.Save(new Contact("Fritz", "Bauer"));

            Mapper.Save(new Contact("Annemarie", "Aal"));

            Mapper.Save(new Contact("Hans", "Habicht"));

            Mapper.Save(new Contact("Olaf", "Schubert"));




             * Search "Annemarie" and "Olaf" using the InCondition


            InCondition condition = new InCondition(typeof(Contact), "FirstName", "Annemarie", "Olaf");

            IList result = Mapper.Select(typeof (Contact), condition);


.. or

            InCondition condition = new InCondition(typeof(Contact), "FirstName", "Annemarie", "Olaf", "Fritz");


You can also put a IList object into the InCondition. This enables you to use a generic collection e.g. List<string> in order to provide the values for the InCondition.


The biggest changes have been made for the ForeignKey Attribute. In prior versions the foreign key attribute has been a class attribute. Because this wasn’t really generic, I changed the ForeignKey attribute handling so that it can now be used like the Unique attribute. Compound Foreign Keys can now set with Key Groups. So have a look at the following example.



        [ForeignKey(1, typeof(Country), "Key")]

        public string CountryKey


            get { return countryKey; }

            set { countryKey = value; }




        [ForeignKey(1, typeof(Country), "Locale")]

        public new string Locale


            get { return base.Locale; }

            set { base.Locale = value; }



This example creates a compound foreign key to the Country object. 


That’s all for now. So hope you enjoy the new version of the ObjectMapper .NET.



– Gerhard

kick it on

Posted in Releases | No Comments »

New Release – ObjectMapper .NET 1.50.1428.0

Posted by Gerhard Stephan on 29th March 2007

This release is a hot fix for the last version which had a small bug. In some special cases the ObjectMapper .NET wasn’t been able to deep load the object.

There had been some dependencies to get the bug, but it wasn’t impossible 🙂

  • You’re working with General Links.
  • You’re working with GetNestedObject and/or GetNestedCollection
  • And you’re working with FlatSelect and than Select to load an object with full hierarchy.

This bug should now be fixed.

– Gerhard

kick it on

Posted in Releases | No Comments »

New Release – ObjectMapper .NET 1.50.1419.0

Posted by Gerhard Stephan on 21st March 2007

Today I’m proud to present you the new release of the AdFactum ObjectMapper .NET.

This release has the most changes in method GetNestedObject and GetNestedCollection. Both methods can now handle nested objects or collections that have been tagged with the [GeneralLink] attribute. As a consequence of that change the GetNestedCollection method does not need the child type parameter any more. Which might result in code changes within your application.

So have fun with it.

– Gerhard

kick it on

Posted in Releases | No Comments »

New Release – ObjectMapper .NET 1.50.1312.0

Posted by Gerhard Stephan on 13th February 2007

Due to the amount of changes within the current version it’s time to increase the release number to 1.50.

First of all the AdFactum ObjectMapper .NET can now handle database functions on properties. Thus enables you to execute database functions when a new object will be inserted, updated or selected. I originally implemented the database function support to read an Oracle sequence number when a new object will be inserted. But it can also be used to set the creation date automatically.

        /// <summary>

        /// Gets or sets the creation.

        /// </summary>

        /// <value>The creation.</value>


        public DateTime Creation


            get { return creation; }

            set { creation = value; }



Furthermore I optimized the way the ObjectMapper .NET writes queries that starts with an "*". The old version of the ObjectMapper .NET put the complete value into a parameter. But that’s not very smart, because the database can’t optimize the query. So, whenever a query starts with a "*" the ObjectMapper .NET will output a built up value like "%" & P1. Thus allows the database optimizer to speed up the query.

Also I added a new tutorial that shows how to use the ObjectMapper .NET within a multithreaded environment. As soon I have time I’m going to write an Article about that Tutorial 04 and post it to that blog.

The last enhancement is a little bit hidden in the meta model of the ObjectMapper .NET. Because we needed to store data changes in our current project, I extended the Meta Model of the Object Mapper .NET in order to store the old property values. If you want to store your data changes, you have to inherit an existing persister and overwrite the methods "Update", "Insert" or "Delete". The parameter "Fields" knows the old and new values which enables you to write a change log of your properties.

Additionally I fixed some bugs within the old version:

  • The AccessPersister is now multi threading compatible.
  • Sometimes the XML Persister threw an NullPointerException. This bug has been fixed.
  • I completed the internal meta model. In some cases the AdFactum ObjectMapper .NET did not own a complete meta model of the data.


Posted in Releases | No Comments »