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

Many to Many Join with Payload?

3 Answers 283 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kevin White
Top achievements
Rank 2
Kevin White asked on 14 Feb 2011, 06:08 PM
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"?

3 Answers, 1 is accepted

Sort by
0
Zoran
Telerik team
answered on 18 Feb 2011, 09:22 AM
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
0
Kevin White
Top achievements
Rank 2
answered on 18 Feb 2011, 03:37 PM
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.
0
Zoran
Telerik team
answered on 24 Feb 2011, 06:59 PM
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!
Tags
General Discussions
Asked by
Kevin White
Top achievements
Rank 2
Answers by
Zoran
Telerik team
Kevin White
Top achievements
Rank 2
Share this question
or