Hibernate version:NHIbernate 1.2
Mapping documents:NHibernate.mapping.attributes
Generate mapping document:
Code:
<class name="KingonSoft.House.Entity.Role, KingonSoft.House.Entity" table="up_role">
<id name="Id" column="id" type="long">
<generator class="native" />
</id>
<property name="RoleTypeId" type="long" column="role_type_id" />
<property name="Name" type="String" column="name" length="20" />
<property name="Description" type="String" column="description" length="255" />
<many-to-one name="RoleType" class="KingonSoft.House.Entity.RoleType, KingonSoft.House.Entity" column="role_type_id" update="false" insert="false" />
<set name="Users" table="up_user_role">
<key column="role_id" />
<many-to-many class="KingonSoft.House.Entity.User, KingonSoft.House.Entity" column="user_id" />
</set>
<set name="Permissions" table="up_role_permission">
<key column="role_id" />
<many-to-many class="KingonSoft.House.Entity.Permission, KingonSoft.House.Entity" column="permissin_id" />
</set>
</class>
<class name="KingonSoft.House.Entity.RoleType, KingonSoft.House.Entity" table="up_role_type">
<id name="Id" column="id" type="long">
<generator class="native" />
</id>
<property name="Name" type="String" column="name" length="50" />
<property name="Description" type="String" column="description" length="255" />
<set name="Roles" lazy="true" cascade="delete-orphan" inverse="true">
<key column="role_type_id" />
<one-to-many class="KingonSoft.House.Entity.Role, KingonSoft.House.Entity" />
</set>
</class>
When I use IList<Role> GetRoleList() it alwayls not update the RoleType until I start a new page.
Example:
there are two roletype entity:
id name
1 roleType1
2 roleType2
gridview display
id roleName roleType.Name
1 role1 roleType1
2 role2 roleType2
when i edit role1 role.roleTypeId form 1 to 2 in gridview updating event function it display like:
id roleName roleType.Name
1 role1 roleType1
2 role2 roleType2
until I start a new page or restart a new edit event;
id roleName roleType.Name
1 role1 roleType2
2 role2 roleType2
anybody can help me? thanks .
the code is belowCode:
IList<Role> list = _roleBLL.GetRoleList();
grvRole.DataSource = list;
grvRole.DataKeyNames = new String[] {"Id"};
grvRole.DataBind();
<asp:TemplateField HeaderText="角色类型" SortExpression="RoleTypeId">
<EditItemTemplate>
<asp:DropDownList ID="drpRoleType" runat="server">
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblRoleType" runat="server" Text='<%# Eval("RoleType.Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
When I change the roletype in dropdownlist like this:
[code]
long id = int.Parse(lblId.Text);
Role role = _roleBLL.Load(id);
role.Name = txtName.Text;
role.Description = txtDescription.Text;
role.RoleTypeId = int.Parse(drpRoleType.SelectedValue);
_roleBLL.Update(role);
grvRole.EditIndex = -1;
//grvRoleBind();
IList<Role> list = _roleBLL.GetRoleList();
grvRole.DataSource = list;
grvRole.DataKeyNames = new String[] {"Id"};
grvRole.DataBind();
[code]
its value of RoleTypeId was changed, but if you watch the value of RoleType. it doesn't change.
if you refresh your page or start a new edit upage in gridview.now the value of roletype will get a new value.
is there a cache? when you update the value then immediately in , perhapse in the same session, reget his value, the value is old.