Reputation: 1436
I want to join two tables in NHibernate 2.1 with the xml mapping.
The parent class (Table1) has a property that is a List of the other class (Table2).
Now class1 has two properties that I want two join with class2.
These are the tables I tried to simplify for this example:
So class1 should be like:
public class class1{
public IList<class2> Class2Items{ get; set;}
}
Like I said, this is a simplified example, so I don't want to mirror the properties from class2 to class1. I want a List of class2 elements in class1. The join would be for 'Type' and 'Number'.
Upvotes: 0
Views: 346
Reputation: 33262
You can use a bag:
<class name="Class1"
table="Table1">
<bag name="Items" cascade="all">
<key column="FK_to_table1"/>
<one-to-many
class="Class2"/>
</bag>
</class>
more info on that topic can be found here.
Upvotes: 1