//添加用户名数据 public void AddUser(User user) { using (var session = NHibernateHelper.OpenSession()) { using (var transaction = session.BeginTransaction()) { session.Save(user); transaction.Commit(); } } }
public List<Role> GetRoleListByUser(User user) { using (var session = NHibernateHelper.OpenSession()) { using (var transaction = session.BeginTransaction()) { var res = session.QueryOver<Role>().Where(role => role.User == user); transaction.Commit(); return (List<Role>) res.List<Role>(); } } }