I have a class called Team, that can have any number of optional TeamMembers.
There appears to be 4 ways to declare it using EF / LINQ to Entities.
If the team class declares a List property, the TeamMember class can declare:
Nothing
The TeamID as an int property
The Team as a object property
Both TeamID and Team properties
What is the difference in the following declarations? Why would / should I choose one over another?
I understand that if I don't specify a Team / ID property, then I won't be able to access that from a TeamMember object. But beyond that how does it affect the DB relationships?
Class Team
{
List<TeamMember> TeamMembers {get;set;}
....
}
// implementation 1
Class TeamMember
{
string Name {get;set;}
...
}
// implementation 2
Class TeamMember
{
Team Team {get;set;}
string Name {get;set;}
...
}
// implementation 3
Class TeamMember
{
int TeamID {get;set;}
string Name {get;set;}
...
}
// implementation 4
Class TeamMember
{
Team Team {get;set;}
int TeamID {get;set;}
string Name {get;set;}
...
}