Beispiel #1
0
 public void Eliminar()
 {
     try
     {
         using (var ctx = new TestContex())
         {
             ctx.Entry(this).State = System.Data.Entity.EntityState.Deleted;
             ctx.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #2
0
        public void Guardar()
        {
            try
            {
                using (var ctx = new TestContex())
                {
                    if (this.id > 0)
                    {
                        ctx.Entry(this).State = System.Data.Entity.EntityState.Modified;
                    }
                    else
                    {
                        ctx.Entry(this).State = System.Data.Entity.EntityState.Added;
                    }

                    ctx.SaveChanges();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }