public virtual void Update(T entity) { if (entity == null) { throw new ArgumentNullException(); } Entities.AddOrUpdate(entity); _context.SaveChanges(); }
public virtual dynamic AddOrUpdate(params T[] objs) { foreach (var obj in objs) { obj.CompanyId = CompanyId; Entities.AddOrUpdate(obj); } SaveChanges(); return(OperateResult.Success()); }
public void Update(T entity) { try { ValidateEntity(entity); Entities.AddOrUpdate(entity); _context.SaveChanges(); } catch (DbEntityValidationException ex) { throw ExceptionHandler(ex); } }
public T Update(T entity) { try { if (entity == null) { throw new ArgumentNullException("entity"); } Entities.AddOrUpdate(entity); _context.SaveChanges(); return(entity); } catch (DbEntityValidationException dbEx) { throw BuildException(dbEx); } }
public void Update(T entity) { try { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } Entities.AddOrUpdate(entity); _context.SaveChanges(); } catch (DbEntityValidationException dbEx) { foreach ( var validationError in dbEx.EntityValidationErrors.SelectMany(validationErrors => validationErrors.ValidationErrors)) { _errorMessage += Environment.NewLine + $"Property: {validationError.PropertyName} Error: {validationError.ErrorMessage}"; } throw new Exception(_errorMessage, dbEx); } }