public class Role
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual int Level { get; set; }
public virtual bool Isman { get; set; }
public virtual User User { get; set; }
}
}
public class User
{
public virtual int Id { get; set; }
public virtual string Username { get; set; }
public virtual string Password { get; set; }
public virtual int Age { get; set; }
public virtual string Email { get; set; }
}
}
子表是role,父表是user
roletemp.User = peer.LoginUser;
public void SaveRole(Role role) {
using (var session = NhibernateHelper.OpenSession())
{
using (var transaction = session.BeginTransaction())
{
session.Save(role);
transaction.Commit();
}
}
}
执行出错 object references an unsaved transient instance before flushing
要怎么改能保存role?
save-update