public void Delete(T entity) { //_context.ObjectContext.AttachTo("SinavGorevli", entity); _objectSet.Attach(entity); _objectSet.DeleteObject(entity); _context.ObjectContext.SaveChanges(); }
public void Update(T entity) { if (entity == null) { throw new ArgumentNullException("entity"); } if (!IsAttached(entity)) { objectSet.Attach(entity); } context.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified); context.ApplyCurrentValues(entitySet.Name, entity); context.SaveChanges(); }
public virtual TEntity Update(TEntity entity) { _objectSet.Attach(entity); _objectSetFactory.ChangeObjectState(entity, EntityState.Modified); return(entity); }
public void Remover(TEntidad entidad) { if (entidad == null) { throw new ArgumentNullException("entidad", "La entidad no puede ser null."); } IObjectSet <TEntidad> objectSet = _unidadDeTrabajo.CrearSet <TEntidad>(); objectSet.Attach(entidad); objectSet.DeleteObject(entidad); }
public void Update(TEntity entity) { if (_config.InsertAllowed) { _objectSet.Attach(entity); _objectContext.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified); } else { throw new InvalidOperationException(); } }
/// <summary> /// <see cref="IRepository{TEntity}"/> /// </summary> /// <param name="item"><see cref="IRepository{TEntity}"/></param> public virtual void Remove(TEntity item) { CheckEntity(item); IObjectSet <TEntity> objectSet = CreateSet(); objectSet.Attach(item); objectSet.DeleteObject(item); Trace(Resources.Messages.trace_DeletedItemRepository); }
public void Registrar(TEntidad entidad) { if (entidad == null) { throw new ArgumentNullException("entidad", Mensajes.EntidadNula); } IObjectSet <TEntidad> objectSet = _unidadDeTrabajo.CrearSet <TEntidad>(); objectSet.Attach(entidad); _manejadorDeTrazas.TrazarInformación(string.Format(CultureInfo.InvariantCulture, Mensajes.TrazaRepositorioRegistrar, typeof(TEntidad).Name)); }
/// <summary> /// Deletes the specified entitiy /// </summary> /// <param name="entity">Entity to delete</param> /// <exception cref="ArgumentNullException"> if <paramref name="entity"/> is null</exception> public bool Delete(T entity) { if (entity == null) { throw new ArgumentNullException("entity"); } _objectSet.Attach(entity); _objectSet.DeleteObject(entity); _context.ObjectStateManager.ChangeObjectState(entity, System.Data.EntityState.Deleted); try { SaveChanges(); return(true); } catch (Exception ex) { return(false); } //finally //{ // Dispose(); //} }
/// <summary> /// <see cref="Microsoft.Samples.NLayerApp.Domain.Core.IRepository{TEntity}"/> /// </summary> /// <param name="item"><see cref="Microsoft.Samples.NLayerApp.Domain.Core.IRepository{TEntity}"/></param> public virtual void Remove(TEntity item) { //check item if (item == (TEntity)null) { throw new ArgumentNullException("item", Resources.Messages.exception_ItemArgumentIsNull); } IObjectSet <TEntity> objectSet = CreateSet(); //Attach object to unit of work and delete this // this is valid only if T is a type in model objectSet.Attach(item); //delete object to IObjectSet for this type objectSet.DeleteObject(item); _TraceManager.TraceInfo( string.Format(CultureInfo.InvariantCulture, Resources.Messages.trace_DeletedItemRepository, typeof(TEntity).Name)); }
public void Attach(T entity) { _objectSet.Attach(entity); _context.ObjectContext.SaveChanges(); }
/// <summary> /// Attaches a entidade especificada /// </summary> /// <param name="entity">entidade para attach</param> public void Attach(T entidade) { _objectSet.Attach(entidade); }
public void Edit(TEntity entity) { _objectSet.Attach(entity); _context.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified); }
/// <summary> /// Faz a edição dos dados de uma entidade /// </summary> /// <param name="entidade">entidade que deve ser removida</param> public void Editar(T entidade) { _objectSet.Attach(entidade); _context.ObjectStateManager.ChangeObjectState(entidade, EntityState.Modified); }
/// <summary> /// Attaches the specified entity /// </summary> /// <param name="entity">Entity to attach</param> public void Attach <T>(T entity) where T : EntityObject { IObjectSet <T> objectSet = context.CreateObjectSet <T>(); objectSet.Attach(entity); }
public void Update(T entitiy) { _objectSet.Attach(entitiy); _contex.ObjectContext.SaveChanges(); }
public void Attach(T entity) { CompleteValidate(entity); _objectSet.Attach(entity); }
public void Attach(T entity) { _objectSet.Attach(entity); Context.ObjectStateManager.ChangeObjectState(entity, System.Data.Entity.EntityState.Modified); }
/// <summary> /// Attaches the specified entity /// </summary> /// <param name="entity">Entity to attach</param> public void Attach(T entity) { _objectSet.Attach(entity); }
public void Update(T entity) { _objectSet.Attach(entity); _objectSetFactory.ChangeObjectState(entity, EntityState.Modified); }