here's the problem: i have a table "Player" and a table "Team". Each team has a some players and players can play in more than one team. So i created a foreign-key-only table "PlayersInTeams" with many-to-one foreign keys to "Team" and "Player". In my project
(VS 2010, ASP.NET 4, C#), I would like to make teamlists of players. The default filters for the "Player" reference only to "PlayersInTeams" instead of "Team" and vice versa. How can i manage this?
Yes, regarding the msdn-article, the PlayersInTeam is a pure-join-table (PJT) and should be eliminated by the many-to-many relationship between "Player" and "Team". This doesn't work in VS 2010 datamodel-designer. The entity "PlayersInTeams" is present,
also the two one-to-many relations between "Player" and "PlayersInTeams" and between "Team" and "PlayersInTeams". BTW: The model is created from a underlying MS SQL-server database.
How can I create the many-to-many-realationship in the datamodel designer?
OK, it works. The problem was, that the "PlayersInTeams"-table was not a real PJT, but had its own id as primary key. That wouldn't work in the VS model designer.
But i've got one more question: how can i change the appearance of the "Teams"-Page? Which field templates are used for that? My goal is to create good readable teamplayer-lists with address and email etc. for each team. What would be the easiest approach
for that?
Yes, regarding the msdn-article, the PlayersInTeam is a pure-join-table (PJT) and should be eliminated by the many-to-many relationship between "Player" and "Team". This doesn't work in VS 2010 datamodel-designer. The entity "PlayersInTeams" is present, also
the two one-to-many relations between "Player" and "PlayersInTeams" and between "Team" and "PlayersInTeams". BTW: The model is created from a underlying MS SQL-server database.
This is because the M:M relationship is aPJT and can only be that sorry
Tillmann
How can I create the many-to-many-realationship in the datamodel designer?
this is not possible as it will need a PJT in the DB.
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
Tillmann
Member
19 Points
16 Posts
Creating a Filter for Foreign-Key-Only Tables
Apr 26, 2012 02:37 PM|LINK
Hi there,
here's the problem: i have a table "Player" and a table "Team". Each team has a some players and players can play in more than one team. So i created a foreign-key-only table "PlayersInTeams" with many-to-one foreign keys to "Team" and "Player". In my project (VS 2010, ASP.NET 4, C#), I would like to make teamlists of players. The default filters for the "Player" reference only to "PlayersInTeams" instead of "Team" and vice versa. How can i manage this?
Regards
Tillmann
mameenkhn
Contributor
2026 Points
391 Posts
Re: Creating a Filter for Foreign-Key-Only Tables
Apr 26, 2012 03:12 PM|LINK
You have to use many to many relationship at database level check the below links for more info.
http://msdn.microsoft.com/en-us/library/dd742359.aspx
http://blogs.msdn.com/b/davidebb/archive/2008/10/25/a-many-to-many-field-template-for-dynamic-data.aspx
http://forums.asp.net/t/1307479.aspx/1
--------------------------------------------------
Muhammad Amin
محمد امين
valZ
Member
128 Points
40 Posts
Re: Creating a Filter for Foreign-Key-Only Tables
Apr 26, 2012 04:07 PM|LINK
Hi, Tillmann.
In my opinion, you need to view a "PlayersInTeams" table. It should have two filters "Players" and "Teams"
Tillmann
Member
19 Points
16 Posts
Re: Creating a Filter for Foreign-Key-Only Tables
Apr 26, 2012 04:19 PM|LINK
Yes, regarding the msdn-article, the PlayersInTeam is a pure-join-table (PJT) and should be eliminated by the many-to-many relationship between "Player" and "Team". This doesn't work in VS 2010 datamodel-designer. The entity "PlayersInTeams" is present, also the two one-to-many relations between "Player" and "PlayersInTeams" and between "Team" and "PlayersInTeams". BTW: The model is created from a underlying MS SQL-server database.
How can I create the many-to-many-realationship in the datamodel designer?
Regards
Tillmann
Tillmann
Member
19 Points
16 Posts
Re: Creating a Filter for Foreign-Key-Only Tables
Apr 27, 2012 10:19 AM|LINK
OK, it works. The problem was, that the "PlayersInTeams"-table was not a real PJT, but had its own id as primary key. That wouldn't work in the VS model designer.
But i've got one more question: how can i change the appearance of the "Teams"-Page? Which field templates are used for that? My goal is to create good readable teamplayer-lists with address and email etc. for each team. What would be the easiest approach for that?
Regards
Tillmann
sjnaughton
All-Star
27320 Points
5459 Posts
MVP
Re: Creating a Filter for Foreign-Key-Only Tables
Apr 27, 2012 11:28 AM|LINK
This is because the M:M relationship is aPJT and can only be that sorry
this is not possible as it will need a PJT in the DB.
Always seeking an elegant solution.
sjnaughton
All-Star
27320 Points
5459 Posts
MVP
Re: Creating a Filter for Foreign-Key-Only Tables
Apr 27, 2012 11:29 AM|LINK
the field template is ManyToMany and ManyToMany_Edit
Always seeking an elegant solution.