Below is mapping and code.
<class name="State" table="State" lazy="true">
<cache usage="read-write"/>
<id name="ID" type="System.Int32" column="Id">
<generator class="identity"/>
</id>
<version name="Version" column="Version" type="System.Int32"
access="property"/>
<property name="StateName" column="StateName" type="System.String"
not-null="true" length="50"/>
<bag name="CityList" table="City" inverse="true" lazy="true"
cascade="save-update">
<cache usage="read-write"/>
<key column="Id"/>
<one-to-many class="City"/>
</bag>
</class>
<class name="City" table="City" lazy="true">
<cache usage="read-write"/>
<id name="ID" type="System.Int32" column="Id">
<generator class="identity"/>
</id>
<version name="Version" column="Version" type="System.Int32"
access="property"/>
<property name="CityName" column="CityName" type="System.String"
not-null="true" length="50"/>
<many-to-one name="State" column="Id" class="State" cascade="none"
update="true" insert="true" not-found="ignore" not-null="false"/>
</class>
//Working successfully - in below code, state shows newly added city
correctly after saving. no need of any refresh
City newcity = new City();
newcity.CityName = "test";
newcity.State = st;
st.City.Add(newcity);
Utility.Save(st); //we are executing save on state object
//Not Working - in below code, state does not show newly added city
until we execute refresh on state
City newcity = new City();
newcity.CityName = "test";
newcity.State = st;
//st.City.Add(newcity); //here we are not adding newcity in
state list (this line is different from above successful code)
Utility.Save(newcity); //we are executing save on city object
(this line is different from above successful code)
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.