I'm working on a project which handles Users and Projects:
- A user may be assigned to zero or X projects.
- A user has read or write rights on a project.
In my database, I have a table named Users_Projects_Rights, which is used to associate a user to a certain number of projects, as well as specify their access rights on them (it's simply a boolean value, true for write rights, false for read rights).
The Users_Projects_Rights table columns are:
- id_User
- id_Project
- CanWrite (boolean)
My User class currently has this collections:
/// <summary>
/// Gets or sets a user's accessible projects, with the value being
/// the name of the project.
/// </summary>
public virtual IDictionary<int, string> AssignedProjects { get; set; }
Taking in consideration that I have a Projects table, which has a Name column:
- How can I map my AssignedProjects dictionnary, in my User class, in order to have the project Id as the key (using a ternary mapping with the Users_Projects_Rights table) and the project name (taken from the Projects table) as the value ?
Here is what I came up with, but I have no idea how to map the value of the dictionary:
<map name="AssignedProjects" table="Users_Projects_Rights">
<key column="id_User"/>
<map-key column="id_Project" type="Int32"/>
(How do I map the value... ?)
</map>