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

Many to Many Relations

2 Answers 119 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Burim
Top achievements
Rank 1
Burim asked on 29 Jul 2011, 09:59 PM
Hi,
I am currently evaluating the product and going through the features according to some scenarios I have. One such scenario is the following:

I have one table Users and one table Roles. I have a many to many relationship between them through a table called UserRoles. I was able to get everything working if the UserRoles table contained only two columns (IDs of the other tables) which also formed the PrimaryKey to the table.
I need to be able to have more fields in the table UserRoles such as DateCreated, UserCreated etc. Is there a way to accomplish that?

Best Regards,
Burim Ratkoceri

2 Answers, 1 is accepted

Sort by
0
Accepted
Ivailo
Telerik team
answered on 02 Aug 2011, 09:30 AM
Hello Burim,

As far as I understand, you are using the Many to Many association between Users and Roles with a join table UserRoles, so that UserRoles is not present in your model.

In order to make the additional fields available, you will have to map this relationship using the other option – presenting the UserRoles class in the domain model, so that instead of Many to Many relation between User and Role you will have a diagram like the one attached.

To achieve that, first go to your Model Schema Explorer and set the IsJoinTable property of the UserRoles table to False. Then drag & drop the table into your diagram and the associations should be automatically created.

This way you will be able to use any additional fields that come with the UserRoles table.  The only disadvantage is that you won’t have a direct link from a User to the Role and vice versa – you will have to use the UserRoles collection instead.

I am looking forward to your feedback.


Greetings,
Ivailo
the Telerik team
Want to use Telerik OpenAccess with SQL Azure? Download the trial version today. 
0
Burim
Top achievements
Rank 1
answered on 02 Aug 2011, 10:04 AM
Hi Ivailo,

Thanks for the response. I was actually quite crazy about the direct link that OpenAccess provided on many to many relations. However I will try the other approach which is not bad either but I kind of miss the direct link :-)

Thanks,
Burim
Tags
Data Access Free Edition
Asked by
Burim
Top achievements
Rank 1
Answers by
Ivailo
Telerik team
Burim
Top achievements
Rank 1
Share this question
or