AdFactum ObjectMapper .NET Blog

Official blog of the AdFactum ObjectMapper .NET

Hierarchy Level Explained

Posted by Gerhard Stephan on October 1st, 2007

The AdFactum ObjectMapper .NET uses hierarchy levels to define the degree of dependence that will be considered when loading or saving.

When loading with hierarchy level 0, the object will be loaded into memory without any dependencies. The same happens when the AdFactum ObjectMapper.NET is storing the objects to database. That means HierarchyLevel.FlatObject, loading and storing without any object dependencies.

For load operations the hierachy level step is always 2.

        public const int FlatObject = 0;

        public const int Dependend1stLvl = 2;

        public const int Dependend2ndLvl = 4;

        public const int AllDependencies = int.MaxValue;

 

In the following example you can see the object dependencies when loading the customer object.

 

For example, when loading the customer with HierarchyLevel.Dependent1stLvl the aggregated Order Objects will be loaded too. When loading the customer with HierarchyLevel.Dependent2ndLvl the OrderItems of the Order Object will be also loaded.

When storing objects to database the Hierarchy Level is even more senstive. That means that you can also specify, whether an object should only update the links to an aggregated object or whether the object should also update the aggregated object too.

These are the intermediate steps 1, 3, 5 and so on. That is, if you only add an existing OrderItem to the Order object, you can store the Order Object with the HierarchyLevel.FlatObjectWithLinks, which updates the link to the OrderItem, but not the OrderItem itself. The difference is very important to know.

For load operations the hierachy level step is always 1.

        public const int FlatObject               = 0;

        public const int FlatObjectWithLinks      = 1;

        public const int Dependend1stLvl          = 2;

        public const int Dependend1stLvlWithLinks = 3;

        public const int Dependend2ndLvl          = 4;

        public const int Dependend2ndLvlWithLinks = 5;

        public const int AllDependencies          = int.MaxValue;

 

In the following example you can see the object dependencies when storing the customer object.

 

For a better understanding I recommend you to output the SQL trace and try to store the object with a different hierarchy levels. That gives you a feeling for, which hierarchy level you use best to get the optimal performance.

 

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>