Beispiel #1
0
 TEntity IRepositoryContext <TEntity> .Post(TEntity entityObject)
 {
     try
     {
         entity = ctx.Set <TEntity>().Add(entityObject);
         ctx.SaveChanges();
     }
     catch (Exception)
     {
         throw;
     }
     return(entity);
 }
Beispiel #2
0
        public int updateBairro(Enderecos endereco)
        {
            int retorno = 0;

            try
            {
                db.Entry(endereco).State = EntityState.Modified;
                retorno = db.SaveChanges();
            }
            catch (DbUpdateException ex)
            {
                throw ex;
            }

            return(retorno);
        }
Beispiel #3
0
 TEntity IRepositoryContext <TEntity> .Delete(Func <TEntity, bool> predicate)
 {
     using (ctx = new DataContexto())
     {
         ctx.Set <TEntity>().Where(predicate).ToList().ForEach(d => { entity = ctx.Set <TEntity>().Remove(d); });
         ctx.SaveChanges();
         return(entity);
     }
 }