This is a migrated thread and some comments may be shown as answers.

How to add/set vertical inheritance in Domain Model designer

9 Answers 204 Views
Design Time (Visual Designer & Tools)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Hendrik
Top achievements
Rank 2
Hendrik asked on 17 Mar 2010, 11:46 AM
How do I add/set vertical inheritance in Domain Model designer? I can set the base/super class to abstract, but the drop down menu to select the base/super class to inherit from is disabled when I want to add inheritance to another class. My database model looks pretty much the same as the one in the documentation page about this subject:

www.telerik.com/help/openaccess-orm/classes-inheritance.html

I did have to change the accosioation between the base table and inheriting table: target multiplicity was set to "ZeroMany" but both source- and target multiplicity should be set to "One" (1:1 relation), not?

I hope you guys can tell me how to do this. None of the examples in the documentation explain how to do this using the Domain Model designer. And using the Domain Model designer should be the preferred approach when starting from an existing database mode.



9 Answers, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 18 Mar 2010, 05:25 PM
Hello Hendrik,

First you have to remove all existing associations between the base and the derived class (if any). Then from the Toolbox window select the Inheritance tool, click on the derived type and drag the mouse over the base type, then release the button;
This will create an inheritance relationship between the classes. You may have to additionally disable the identity fields of the derived classes as they will use the identity of the base type. This can be done by selecting the identity field and setting the Identity property in the Properties window to False;
Hope that helps.

Regards,
Alexander
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Sörnt Poppe
Top achievements
Rank 1
answered on 25 Mar 2010, 01:17 PM
How do I create a sub class (flatt mapping) within the DSL designer?

I have got the following table:

ProjectItemStatusAttribut(
    [PISA_Id] [int] IDENTITY(1,1) NOT NULL,
    [voa_class] [int] NOT NULL,
    [PISA_Name] [nvarchar](50) NOT NULL,
    [PISA_Value] [nvarchar](50) NOT NULL
)
The field "voa_class" is the discriminator field. Is the field name "voa_class" fix or can I rename it to something else?

I now want to have different sub classes. For example a ProjectPriority class. That class have no additional fields.
I guessed that I need to:
  • set the generated class "ProjectItemStatusAttribut"  to "abstract" at the property window
  • delete (unmapp) the field "vao_class" from the DSL designer
  • set the "Discriminator column" to "voa_class" and check the option "Class ID" at the "Discriminator value" group within the "Mapping Details Editor"

But now, how to add a sub class? If I drag&drop a MetaClass "Icon" from the Toolbox to the DSL designer I get the message "All available tables in the relational model are alreday mapped".

What do I need to do?

Kind regards,
Sörnt
0
Hendrik
Top achievements
Rank 2
answered on 25 Mar 2010, 04:17 PM
Next problem :-) For the classes inheriting my base class I would want to use my own discriminator columns instead of the default 'voa_class'. And as a discriminator value I want to use a custom set value. Both these values can be set using the Domain Model designer, but the discriminator column value doesn't seem to be saved. When checking the generated class I see and attribute 'InheritanceMapping'. This attribute contains values for 'DiscriminatorValue' and 'InheritanceStrategy', but 'DiscriminatorColumn' seems to be missing.

For the time being I have manually added the 'voa_class' column, but the next problem occurs: when trying to inserting a row into the inheriting table (I have a class Client and two inheriting classes 'Company' and 'Person', pretty basic...) I get a SQL insert error, which is too large to post here :-). In short the error occurs because the insert statement contains two SET statements for the key column, in my case 'ClientId'. Probably once for the base class 'Client' and once for the inheriting class 'Company'. For the base class this column is an auto-increment column, which should not be included in the insert statement. For the inheriting class the 'ClientId' key column should be set to the newly inserted identity of the base class (vertical inheritance).

Is this a bug, of am I doing something wrong?
0
Sörnt Poppe
Top achievements
Rank 1
answered on 26 Mar 2010, 09:07 PM
I opend a support Ticket and got allready a response:

Flat mapping is not supported by the DSL designer. Will be added within Q2 2010.

Sörnt
0
Hendrik
Top achievements
Rank 2
answered on 30 Mar 2010, 08:23 AM
Sörn, for the record: your answer isn't a response to my question, is it? The scenario I described isn't flat mapping, it's vertical Inheritance. So for the Telerik guys: my question is still open ;-)
0
Sörnt Poppe
Top achievements
Rank 1
answered on 30 Mar 2010, 08:35 AM
Hi Hendrik,

No, it is not.

Your request is still open. Sorry of hijacking your thread for my inheritance problem!
If you open a support ticket you will get your questions answered faster.

Regards,
Sörnt
0
PetarP
Telerik team
answered on 31 Mar 2010, 09:43 AM
Hi,

@Sörnt Poppe:
I am afraid that flat mapping cannot be used at the moment. When we add forward mapping support to the designer (the target is Q2 2010), flat mapping should be supported as well.
The option now is to use vertical mapping which requires each class to have its own table. When you map these tables with the designer you will get all the classes in the hierarchy. Then you will be able to set the inheritance relationships and use the model.

@Hendrik:
You are correct here. We do have some problems with the inheritance details editor and we are addressing them as we speak. I hope that you will be able to find them fixed with our next service pack release. You can find your Telerik points updated for bringing those issues to our attention.

Sincerely yours,
Petar
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Stuart Miller
Top achievements
Rank 1
answered on 19 Jun 2010, 03:43 PM
Petar,

I'm trying to figure out inheritance with the Domain Model as well.  I have the following Schema (abbreviated)

CREATE TABLE tbl_v1_object ( 
    id int PRIMARY KEY IDENTITY(100,1) NOT NULL
    name varchar(50) NOT NULL 
GO 
CREATE TABLE tbl_v1_merchant_item ( 
    itemID int PRIMARY KEY REFERENCES tbl_v1_object(id) NOT NULL
    description varchar(1000) NULL 
GO 

I have set up my EntityDiagram, and used the suggestions of Alexander.  I Added an Object class and a MerchantItem class.  I  added an Inheritance link from MerchantItem to Object and removed the Association link which was automatically added.  I made Id in the Object class Public, and set Identity to True.  In MerchantItem, I made ItemID private and set Identity to False.  In the Error List dialog window, I have Errors which says "The persistant type MerchantItem has no primary key specified.", but the Project will build successfully, so I'm ignoring them.  However, when I go to run the project and fetch the data using the following...

        public IQueryable<MerchantItem> Items { 
            get { 
                MerchantEntityDiagrams med = new MerchantEntityDiagrams("connectionString"); 
                return med.Merchantitems; 
            } 
        } 

... it throws an Exception...

There are more than one db-column extensions used, only one is allowed. --> MerchantEntityDiagrams/namespace[tgs.model]/class[Object]/field[_id]/db-column


Am I going about this in the wrong way?  Does anyone have any suggestions to get this to work?


0
PetarP
Telerik team
answered on 25 Jun 2010, 04:57 PM
Hi Stuart Miller,

We indeed have some problems with the inheritance mapping details editor that we are currently addressing. I believe that you will be able to find all the problems fixed with our next build.
We are sorry for any inconvenience caused.

Regards,
Petar
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Design Time (Visual Designer & Tools)
Asked by
Hendrik
Top achievements
Rank 2
Answers by
Alexander
Telerik team
Sörnt Poppe
Top achievements
Rank 1
Hendrik
Top achievements
Rank 2
PetarP
Telerik team
Stuart Miller
Top achievements
Rank 1
Share this question
or