So, after poking around a bit, I decided going to Dictionary route was likely going to be too painful (although I'd love someone to prove me wrong, since it is the optimal data structure). Instead, I created a class to associate the Company and the User. Here's what the table looks like:
Company_User
CompanyId INT (PK)
UserId INT (PK)
AuthorizationLevelId INT
And here's my mapping file for the CompanyUser class:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="TestProject"
assembly="TestProject">
<class name="CompanyUser" table="Company_User" lazy="false">
<composite-id>
<key-property column="CompanyId" name="Campaign" />
<key-property column="UserId" name="User" />
</composite-id>
<property name="AuthorizationLevel" column="AuthorizationLevelId" />
</class>
</hibernate-mapping>
Lastly, here's the bit of the mapping file in my Company mapping file that wires this all up:
<bag name="_authorizedUsers" access="field">
<key column="CampaignId" />
<one-to-many class="CampaignUser" />
</bag>
I've correctly set up the CompanyUser.hbm.xml file as an embedded resource as well. When I test the code, I get this error:
NHibernate.MappingException: Association references unmapped class: CampaignUser
But this class is mapped. Any ideas?
-Eric
|