Monday, July 29, 2013

Creating object relationships using the application model

In next version of eXpandFramework 13.1.5.13 it will be possible to create associations between business objects. Let’s see in details how this will work.

1. Installation – Prerequisites

The runtime members can be found in the eXpand.ExpressApp assembly, therefore you need to install the XpandSystemModule. However because this assembly has platform specific versions you will not find it in the toolbox and you have to go for its win or web version which is XpandSystemWindowsFormsModule or XpandSystemAspNetModule. To see how easy it is to install the XpandSystemWindowsFormsModule watch the next video. Note that it is also possible to create object relationship for the web.

2. Simple association

In the next video you can see how we can create a relationship between two entities at runtime. To be more specific I will create a relationship between the TopicIcon and The Category business objects. I already have a sample application and logged in as the Admin user so the relationship I will create it will be stored in Admin’s user model. 

3. Creating the many part of the relation

In the next video instead of working with XAF’s default model editor, we will use the ModelDifference module. XAF’s Application Model is by design multi layered and the ModelDifference module exposes this functionality in a more business oriented approach. It is also faster to work with it because as you can watch in the video I only execute the save action without even reloading the model! Even if the ModeDifference module introduces the concept of application models, I am going to use again Admin’s model and I will create an Icons collection for the Category object and I will link the reference TopicIcon Category property I created in previous video. Note to install the ModelDifference module you need to go through the exact steps of step one but this time for the ModelDifferenceWindowsFormsModule.

4. Creating an Orphaned Collection

An orphaned collection does not participate in a relationship however it is possible to be filters. In step three I linked a TopicIcon with a Category and also added a TopicIcon to the same Category instance. Both TopicIcons were of Type Idea. Now I will create an Orphaned collection of all TopicIcons with Type Idea and I will add it to the Category_DetailView.

5. Distributing the Application Model

We already created our relationships in the Admin’s model. However, this means that they can be used only for the Admin user. To confirm this in the next video I will give Edit Model permissions to a normal user and I will login to explore his model. Then I will switch back to the Admin which has permissions to modify ModelDifference module objects. Next I will create a Role model by cloning one of the existing models. Finally I will associate the Role model with the users Role, I will merge it with the Admin’s model and switch back to the User to confirm that he also can see the same as the admin.

Forgot to mention that runtime member creation is now very fast thanks to Sandrowelter (see this thread in eXpand forums).

Happy XAF’ing to all!

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

0 comments:

Post a Comment