Dear all, is there any one to help me with update problem of fluent Nhibernate. I want to update parent and its children.
problem: it is not updating but inserting new rows in database. My code is as below I will be grateful for your helping. Mappings: Parent public class ProjectsMapping : ClassMap<Project> { public ProjectsMapping() { Table("Projects"); Id(u => u.PId).GeneratedBy.Identity(); Map(u => u.Id).Column("ApiProjectId"); Map(u => u.Name); Map(u => u.EditorGuid); Map(u => u.CreatedOn); Map(u => u.CreatedBy); Map(u => u.ModifiedOn); Map(u => u.ModifiedBy); HasMany(u => u.Roles).KeyColumn("RoleProjectId").Inverse().Cascade.AllDeleteOrphan(); } Mapping: children public class RoleMapping : ClassMap<Role> { public RoleMapping() { Table("ModuleRole"); Id(u => u.RId).GeneratedBy.Identity(); Map(u => u.Name); Map(u => u.Site_Id).Column("SiteId"); Map(u => u.Site_Name).Column("SiteName"); Map(u => u.Domain); Map(u => u.EditorGuid); References(x => x.Project).Column("RoleProjectId").Cascade.SaveUpdate().Not.LazyLoad(); } } updating code: public void Update(T entities) { using (ISession _session = DatabaseContext.SessionOpen()) { using (ITransaction _transaction = _session.BeginTransaction()) try { _session.Update(entities); //I tried SaveOrUpdate instead of Update _session.Flush(); _transaction.Commit(); } catch (Exception ex) { if (!_transaction.WasCommitted) { _transaction.Rollback(); } } } } -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/nhusers/f332bf12-2fdc-4834-a3a2-87f76bea5984n%40googlegroups.com.