public List <TEntity> GetAll() { using (var session = HibernateUtil.SessionFactory(connectionString).OpenSession()) { return(session.Query <TEntity>().ToList()); } }
public TEntity GetById(int id) { using (var session = HibernateUtil.SessionFactory(connectionString).OpenSession()) { return(session.Get <TEntity>(id)); } }
public void Remove(TEntity obj) { using (var session = HibernateUtil.SessionFactory(connectionString).OpenSession()) { var transaction = session.BeginTransaction(); session.Delete(obj); transaction.Commit(); } }
public List <AvaliacaoDTO> GroupByAvaliacao() { using (var session = HibernateUtil.SessionFactory(connectionString).OpenSession()) { return(session.Query <AvaliacaoAtendimento>() .GroupBy(a => a.Avaliacao) .Select( result => new AvaliacaoDTO { Avaliacao = result.Key.ToString(), Total = result.Count() } ) .ToList()); } }