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

4 posts, 0 answers
  1. Lars
    Lars avatar
    10 posts
    Member since:
    Oct 2015

    Posted 07 Jun Link to this post

    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.

  2. Doroteya
    Admin
    Doroteya avatar
    502 posts

    Posted 10 Jun Link to this post

    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.
  3. DevCraft banner
  4. Lars
    Lars avatar
    10 posts
    Member since:
    Oct 2015

    Posted 10 Jun in reply to Doroteya Link to this post

    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.

     

  5. Doroteya
    Admin
    Doroteya avatar
    502 posts

    Posted 15 Jun Link to this post

    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.
Back to Top