Take this hypothetical situation. A Person has a collection of Courses. They join on person name (rubbish, i know, but hypothetical).
How would one go about creating a one to many relationship within person, using the PersonName as the joining field. Bearing in mind this is not my <id> field?
What I have below is as far as I have got,
property-ref appears not to work in version 1.0.2, what is the recommendation?
Thank you very much,
Gary
nHibernate 1.0.2
Code:
This section is part of my Person class ->
<set name="Courses" table="Course" inverse="false" lazy="true">
<key column="PersonName" property-ref="Name"/>
<one-to-many class="NHibTest.Course, NHibTestLib"/>
</set>
..................................................................
<class name="NHibTestLib.Course, NHibtestLib" table="Course" lazy="true">
<id name="Id" column="Id" type="Guid" length="32">
<generator class="guid" />
</id>
<property name="PersonName" column="Person" insert="false" update="false"/>
<property name="Name" column="Name" type="String" length="40"/>
</class>
SQL Server 2005
Quote:
create table Course (
[Name] nvarchar(40),
Id uniqueidentifier,
[PersonName] nvarchar(40),
PRIMARY KEY (Id)
)
create table Person (
[Name] nvarchar(40),
Id uniqueidentifier,
pencil uniqueidentifier,
[domicile] nvarchar(40),
[currency] nvarchar(40),
[bigdata] nvarchar(40),
[age] int,
ptype char,
PRIMARY KEY (Id)
)
go