When trying to do a many-to-many relationship I am having trouble with the .NET code.
If I use the non-Generic IDictionary
Code:
public virtual IDictionary Skills
{
get { return _skills; }
set { _skills = value; }
}
I then get the error:
System.InvalidCastException: Unable to cast object of type 'NHibernate.Collection.PersistentSet' to type 'System.Collections.IDictionary'.If I use the Generic version:
Code:
public virtual IDictionary<int, Skill> Skills
{
get { return _skills; }
set { _skills = value; }
}
I get the error:
NHibernate.MappingException: Error mapping generic collection Doa.Domain.Entities.Profile.Skills: expected 1 generic parameters, but the property type has 2
Huh????
How do I pass one parameter to the Generic IDictionary?
More information below.
Thanks,
kellygreer1
Hibernate version:
2.2
Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="Doa.Domain.Entities" assembly="Doa.Domain">
<class name="Profile" table="Profiles">
<id name="Id" column="id" type="Int32" unsaved-value="-1"
access="field.camelcase-underscore">
<generator class="native" />
</id>
<property name="UserName" column="ntlogon" type="string" length="24" access="field.camelcase-underscore">
</property>
<property name="LastName" column="last_name" type="string" length="18" access="field.camelcase-underscore">
</property>
<property name="FirstName" column="first_name" type="string" length="18" access="field.camelcase-underscore">
</property>
<property name="MiddleName" column="middle_name" type="string" length="18" access="field.camelcase-underscore">
</property>
<set name="Skills" table="ProfileSkills">
<key column="profile_id" />
<many-to-many column="skill_id" class="Skill" />
</set>
</class>
</hibernate-mapping>