I've spent the last day or two mulling over how to implement a relation in our database using NHibernate and can't seem to come up with something that works. So I'm hoping there is someone out there who can give me some advice on how best to go about doing this.
I'm dealing with a legacy database so I can't change the schema. I'm trying to model a relationship between a user and location that is defined by a PermissionItem object. The PermissionItem object defines what type of access a user has to the location (eg. read, write, control, etc.). In UML speak, it would look like this:
Code:
+----------------+
| PermissionItem |
+----------------+
|
+------+ * | * +----------+
| User |-----------------------| Location |
+------+ +----------+
In our database, this has been modeled as a four tables: A User table, PermissionItem table, Location table, and a join table that joins these.
Code:
+----------------+
Join Table +------>| PermissionItem |
+------+ +-------------------+ | +----------------+
| User |----> |UserId,PermId,LocId| +
+------+ +-------------------+ | +----------+
+------>| Location |
+----------+
Could someone tell me how I would setup my mappings so that I can create, store and manipulate these relationships?
Thanks
Dave.