public void Guardar(tbl_logEstado data) { try { using (var ctx = new ceContext()) { //Existe ctx.Configuration.AutoDetectChangesEnabled = false; ctx.Configuration.ValidateOnSaveEnabled = false; if (data.id > 0) { ctx.Entry(data).State = EntityState.Modified; } else //nuevo registro { var logData = ctx.Entry(data); logData.State = EntityState.Added; // ctx.Entry(data).State = EntityState.Added; logData.Property(x => x.fecha).IsModified = false; } ctx.SaveChanges(); } } catch (Exception e) { throw; } }
public tbl_logEstado Obtener(int id) { var tblData = new tbl_logEstado(); try { using (var ctx = new ceContext()) { tblData = ctx.tbl_logEstado.Where(x => x.id == id) .SingleOrDefault(); } } catch (Exception) { throw; } return(tblData); }