Thank you for the additional information about your scenario.
In order to access the columns of a table, OpenAccess ORM needs the table to be mapped to a Domain Class
. Unfortunately this means that it is not possible to access the columns of a join table used to directly model m:n association.
However, I can suggest a possible workaround to avoid introducing an additional level to your tree view. When your join table is mapped to a DomainClass (Teammember), you can define two new non persistent
classes which would emulate the structure of directly modeled m:n association and use them to populate your tree view:
- Define a class which has the properties from both Person and Teammember (IsActive and IsLead). For example lets call this class TeammemberCustom.
- Define a class which has the same properties as Team, but Teammembers is a List<TeammembersCustom>. For example lets call this class TeamCustom.
- Then, based on the teams you have in your database, you can get a list of TeamCustom objects like so:
List<TeamCustom> retrievedTeams = context.Teams
TeamId = team.TeamId,
Name = team.Name
- You can now set the Teammember property of each TeamCustom object with the following code:
List<TeamMemberCustom> teamMembers = context.Teams
.FirstOrDefault(team => team.TeamId == currentTeam.TeamId)
Id = member.Person.PersonId,
Name = member.Person.Name,
Address = member.Person.Address,
IsActive = member.IsActive,
IsLead = member.IsLead
currentTeam.Teammembers = teamMembers;
You could now use the retrievedTeams
list to populate your tree view while avoiding the additional level which would be introduced by the class of the join table.
I hope this helps.
OpenAccess ORM Q3 2013 simplifies your model operations even further providing you with greater flexibility. Check out the list of new features
shipped with our latest release!