I have 2 classes.
User and Address
with following mapping
Code:
<class name="ABC.User, ABC"
table="Users">
<id name="ID" column="UserID" type="Int32" unsaved-value="0">
<generator class="native" />
</id>
<property name="Username" column="Username" type="String"/>
<property name="Password" column="Password" type="String"/>
....
....
....
<set name="Addresses" inverse="true" cascade="all" access='NHibernate.Generics.GenericAccessor, NHibernate.Generics' >
<key column="ContactID"/>
<one-to-many class="ABC.Address, ABC"/>
</set>
</class>
<class name="ABC.Address, ABC" table="Addresses">
<cache usage="read-write" />
<id name="ID" column="AddressID" type="Int32" unsaved-value="0">
<generator class="native">
</generator>
</id>
<property name="Address1" column="Address1" type="String" length="50" />
<property name="Address2" column="Address2" type="String" length="50" />
....
....
<many-to-one cascade="save-update"
name='User'
access='NHibernate.Generics.GenericAccessor, NHibernate.Generics'
class='ABC.User, ABC'
column='ContactID' />
</class>
Now i want to make a search form, and since result coming as
Code:
User
Addresses
Address
Address
I can't display it in DataGridView.
I decide to make a separate class UserAddress(flat)
which contain User->Address one-to-one relationship.
I start doing mapping as:
Code:
<class name="ABC.User, ABC"
table="Users">
<id name="ID" column="UserID" type="Int32" unsaved-value="0">
<generator class="native" />
</id>
<property name="Username" column="Username" type="String"/>
<one-to-one name="????" class="ABC.Address, ABC"/>
</class>
And have no idea how to map
in code i want to have
Code:
UserAddress
id;
Username;
Address1;
....
....
Zip
That object is easy bind to grid, and sorting will work.
Anyone can help me to learn NHibernate???
Maybe its other way of doing it??
I tried IQuery but it return ArrayList,but i need also field names
Thanks a lot
gerasha