|
Hi
I am trying to get the value of the column attribute of a many-to-one in C# code. I believe I am close, but I am not sure how to use the .GetIdentifierOrUniqueKeyPropertyName(???) method found in the ManyToOneType class.
Below is the Mapping document, and code I use to get to the above mention method.
Thanks!
Kind Regards,
Nicholas
Hibernate version:
NHibernate 1.2.0
Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Generic2.Security.User, Generic2.Security" table="[User]">
<id name="ID" type="Int32">
<generator class="identity" />
</id>
<property name="UserName" type="String"/>
<property name="Password" type="String" />
<property name="RoleID" type="Int32" />
<many-to-one name="Role" class="Generic2.Security.Role, Generic2.Security" column="RoleID" unique="true"
update="false" insert="false"/>
<property name="FirstName" type="String" />
<property name="LastName" type="String" />
<property name="Enabled" type="Boolean" />
<property name="ChangePassword" type="Boolean" />
<property name="LastPasswordChange" type="DateTime" />
<property name="FailedLogins" type="Int32" />
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
((NHibernate.Type.ManyToOneType)sessionFactory
.GetClassMetadata(typeof(User)).GetPropertyType("Role"))
.GetIdentifierOrUniqueKeyPropertyName(???);
Name and version of the database you are using:
SQL Server 2005
|