public virtual TEntity GetById(int id, params Expression <Func <TEntity, object> >[] includeProperties)
 {
     using (ISession session = DbContexto.AbrirSession())
     {
         try
         {
             return(session.Get <TEntity>(id));
         }
         catch (Exception e)
         {
             this.AddNotification("Buscar entidade base", e.Message);
             return(null);
         }
     }
 }
 public virtual bool IdExiste(int id)
 {
     using (ISession session = DbContexto.AbrirSession())
     {
         try
         {
             TEntity obj = session.Get <TEntity>(id);
             return(obj == null);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
 public virtual List <TEntity> GetAll(params Expression <Func <TEntity, object> >[] includeProperties)
 {
     using (ISession session = DbContexto.AbrirSession())
     {
         try
         {
             return((from e in session.Query <TEntity>() select e).ToList());
             //session.Get<TEntity>(TEntity.Equals);
         }
         catch (Exception e)
         {
             this.AddNotification("Listar entidade base", e.Message);
             return(new List <TEntity>());
         }
     }
 }
        public virtual bool UpDate(TEntity Object)
        {
            bool salve = false;

            using (ISession session = DbContexto.AbrirSession())
            {
                using (ITransaction transacao = session.BeginTransaction())
                {
                    try
                    {
                        session.Update(Object);
                        salve = true;
                    }
                    catch (Exception e)
                    {
                        this.AddNotification("Update entidade base", e.Message);
                    }
                }
            }
            return(salve);
        }
        public override List <Livro> GetAll(params Expression <Func <Livro, object> >[] includeProperties)
        {
            using (ISession session = DbContexto.AbrirSession())
            {
                try
                {
                    var r = session.Query <Livro>()
                            .Fetch(e => e.LivroCategoria);

                    return(r.ToList());

                    //return (from e in session.Query<Livro>()
                    //        .Fetch(e => e.LivroCategoria)
                    //        select e).ToList();
                }
                catch (Exception e)
                {
                    this.AddNotification("Listar entidade base", e.Message);
                    return(new List <Livro>());
                }
            }
        }