コード例 #1
0
 private static void ExecuteQuery(string query)
 {
     using (ISession sessao = SessionNHibernate.Criar().OpenSession())
     {
         using (var transacao = sessao.BeginTransaction())
         {
             sessao.CreateSQLQuery(query).ExecuteUpdate();
             transacao.Commit();
         }
     }
 }
コード例 #2
0
 public Ticket ObterPor(int id)
 {
     try
     {
         using (ISession sessao = SessionNHibernate.Criar().OpenSession())
         {
             return(sessao.Query <Ticket>().FirstOrDefault(onde => onde.Id == id));
         }
     }
     catch
     {
         throw;
     }
 }
コード例 #3
0
 public Ticket ObterUltimo()
 {
     try
     {
         using (ISession sessao = SessionNHibernate.Criar().OpenSession())
         {
             return(sessao.Query <Ticket>().AsQueryable()
                    .Where(UltimoTicket.Hoje)
                    .OrderByDescending(ordem => ordem.DataHoraDeEntrada)
                    .FirstOrDefault());
         }
     }
     catch
     {
         throw;
     }
 }
コード例 #4
0
 public void Salvar(Ticket ticket)
 {
     if (ticket.Valido())
     {
         using (ISession sessao = SessionNHibernate.Criar().OpenSession())
         {
             using (ITransaction trasacao = sessao.BeginTransaction())
             {
                 try
                 {
                     sessao.SaveOrUpdate(ticket);
                     sessao.Flush();
                     trasacao.Commit();
                 }
                 catch
                 {
                     trasacao.Rollback();
                     throw;
                 }
             }
         }
     }
 }