//Respositorio do Country public static void Create() { NhibernateHelper nh = new NhibernateHelper(); using (var sf = nh.CreateSessionFactory()) { sf.Close(); } }
public static Country RetornarPaisesPorId(int id) { NhibernateHelper nh = new NhibernateHelper(); using (var sf = nh.CreateSessionFactory()) using (var session = sf.OpenSession()) using (var transaction = session.BeginTransaction()) { return(session.Get <Country>(id)); } }
public ActionResult <IEnumerable <User> > Get() { List <User> users; var sessionFactory = NhibernateHelper.CreateSessionFactory(); using (ISession session = sessionFactory.OpenSession()) // Open a session to conect to the database { users = session.Query <User>().ToList(); // Querying to get all the books } return(users); }
public static void AddProject(Country country) { NhibernateHelper nh = new NhibernateHelper(); using (var sf = nh.CreateSessionFactory()) using (var session = sf.OpenSession()) using (var transaction = session.BeginTransaction()) { try { session.SaveOrUpdate(country); transaction.Commit(); } catch (Exception e) { throw new Exception("Error ao criar" + e.Message); } } }