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

multiple one-to-one associations to specific sub-class in flat hierarchy - possible?

3 Answers 52 Views
Databases and Data Types
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Lars
Top achievements
Rank 1
Lars asked on 07 Jun 2016, 04:12 PM

Hi,

I have a class model in which several classes have a relation to another set of classes which all derive from a common base class.

E.g. Customer has one CustomerAddress and Supplier has one SupplierAddress. Both CustomerAddress and SupplierAddress derive from Address and all addresses shouuld be stored in a single DB table using InheritanceStartegy.Flat.

How would I map this scenario? I tried along the lines of the one-to-one association sample in the documentation, but this obviously cannot work since it requires identical primary IDs in both tables which reference each other (which seems like a too strict constraint to me, anyway).

Thanks for any hints,

Lars.

3 Answers, 1 is accepted

Sort by
0
Doroteya
Telerik team
answered on 10 Jun 2016, 08:04 AM
Hi Lars,

Telerik Data Access offers an API dedicated to modelling flat inheritance. The tutorial is available in our documentation here. Additionally, I'm attaching a small sample that mimics your scenario based on the provided description.

I hope this helps.

Regards,
Doroteya
Telerik
 
Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
0
Lars
Top achievements
Rank 1
answered on 10 Jun 2016, 11:25 AM

Hi Doroteya,

thanks for your reply. We already use a few flat inheritance hierarchy and fluent mapping, so this is clear to me.

However, the sample differs in the crucial point from my problem: Supplier and Customer each have exactly one address, not a list of addresses. i.e. a one-to-one relation, not one-to-many.

Regards, Lars.

 

0
Doroteya
Telerik team
answered on 15 Jun 2016, 07:02 AM
Hello Lars,

You could map the associations as one-to-one as demonstrated in the updated sample. However, with this setup none of the primary keys could be an autoincrement one. The fact that you are using Flat inheritance prevents it.

I hope this helps.

Regards,
Doroteya
Telerik
 
Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
Tags
Databases and Data Types
Asked by
Lars
Top achievements
Rank 1
Answers by
Doroteya
Telerik team
Lars
Top achievements
Rank 1
Share this question
or