Many to Many Join with Payload?

4 posts, 0 answers
  1. Kevin White
    Kevin White avatar
    60 posts
    Member since:
    Jun 2004

    Posted 14 Feb 2011 Link to this post

    With a 'normal' many to many joins, the designer hides the join details by making properties on the entities that abstract the joining table.
    (See the attached picture, "normal many to many.png")

    Now I have a Many to Many relation that has additional columns on the joining table (the payload).
    (See picture, "database schema.png")

    Because of this, the designer shows the joining table.
    (See the attached picture, "payload many to many.png")

    I would rather hide this joining table. Is it possible to create a Meta Class called "Employee" that flattens the "Person" and "LegalDocumentPerson" entities together.  Such that LegalDocument just a Property called "Employees"?
  2. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 18 Feb 2011 Link to this post

    Hi Kevin White, 

    Yes it is possible to resolve this scenario in the way you have proposed. Here are the technical details:
    • You should create a Database View in your SQL Server Management studio which 'flattens' out the Person and LegalDocumentPerson entities - you can call it Employee.
    • Map the Employee view in your database model and omit the mapping of the Person and LegalDocumentPerson entities in the designer.
    •  Create an association between the Employee and LegalDocument entities and define it properly as a 1:n association.
    Regards,
    Zoran
    the Telerik team
  3. DevCraft banner
  4. Kevin White
    Kevin White avatar
    60 posts
    Member since:
    Jun 2004

    Posted 18 Feb 2011 Link to this post

    But without the mapping it is not updateable though is it?  Guess I could create CRUD stored procs to handle updating multitables in the same transaction.
  5. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 24 Feb 2011 Link to this post

    Hi Kevin White,

     Actually the database Views with OpenAccess are updateable and you could execute CRUD in the very same way as with any normal entity. Stored procedures are not obligatory as, when you update an object mapped to a View, the runtime updates the necessary tables accordingly.

    Regards,
    Zoran
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Back to Top