// Called from the ObjectHandler internal void Update(IHasRowVersion target) { Target = target; Handle = string.Format("{0}:{1}", ObjectType, HandleIndex++); ; LastUpdate = DateTime.Now; // Might be used to decide when or how often to refresh if (Observer != null) Observer.OnNext(Handle); // Triggers the update sending the new handle to Excel }
public virtual void Update(T entity, IHasRowVersion dto) { var entry = ctx.Entry(entity); entry.Property(e => e.RowVersion).OriginalValue = dto.RowVersion; entry.CurrentValues.SetValues(dto); }
// Called from the ObjectHandler internal void Update(IHasRowVersion target) { Target = target; Handle = string.Format("{0}:{1}", ObjectType, HandleIndex++);; LastUpdate = DateTime.Now; // Might be used to decide when or how often to refresh if (Observer != null) { Observer.OnNext(Handle); // Triggers the update sending the new handle to Excel } }
public HandleInfo(ObjectHandler objectHandler, string objectType, object[] parameters, IHasRowVersion target) { // TODO: Complete member initialization Handler = objectHandler; ObjectType = objectType; Parameters = parameters; Target = target; Handle = string.Format("{0}:{1}", objectType, HandleIndex++); LastUpdate = DateTime.Now; }
public virtual async Task <bool> SaveUpdatedWithOptimisticConcurrencyAsync(IHasRowVersion input, IPrincipal principal, Action <string, string> writeError, IDataAccessStrategy <T> savingStrategy = default) { bool result = false; var entity = mapper.Map <T>(input); result = await SaveUpdatedWithOptimisticConcurrencyAsync(entity, principal, writeError, savingStrategy); if (result) { mapper.Map(entity, input); } return(result); }
public virtual bool UpdateWithIncludeOrExcludeProperties(IHasRowVersion source, T destination, bool include, ICollection <string> propertyNames) { var destinationEntry = ctx.Entry(destination); destinationEntry.Property(e => e.RowVersion).OriginalValue = source.RowVersion; var sourceProperties = source.GetProperties(); foreach (var property in sourceProperties) { string propertyName = property.Name; bool contains = propertyNames.Contains(propertyName); if ((contains && include) || (!contains && !include)) { var sourceValue = property.GetPropertyValue(source); destination.SetPropertyValue(propertyName, sourceValue); } } return(true); }
public virtual bool UpdateWithIncludeOrExcludeProperties(IHasRowVersion source, T destination, bool include, params Expression <Func <T, object> >[] properties) { var propertyNames = properties.ConvertArray(ReflectionUtils.GetNameOf); return(UpdateWithIncludeOrExcludeProperties(source, destination, include, propertyNames)); }
public virtual async Task <TOutput> SaveUpdatedWithOptimisticConcurrencyAsync <TOutput>(IHasRowVersion source, T destination, IPrincipal principal, Action <string, string> writeError, IDataAccessStrategy <T> savingStrategy = default) { savingStrategy = savingStrategy ?? dataAccessStrategy; savingStrategy.ThrowIfNull(nameof(savingStrategy)); TOutput result = default; if (savingStrategy.CanUpdate(destination)) { if (savingStrategy.CanUpdateAllProperties(destination)) { mapper.Map(source, destination); } else { var properties = savingStrategy.GetPropertiesForUpdate(destination); UpdateWithIncludeOrExcludeProperties(source, destination, true, properties); } bool success = await SaveUpdatedWithOptimisticConcurrencyAsync(destination, writeError, false); if (success) { result = mapper.Map <TOutput>(destination); } } else { writeError("", Resources.ErrorMessages.AccessDenied); } return(result); }
public virtual async Task <TOutput> SaveUpdatedWithOptimisticConcurrencyAsync <TOutput>(IHasRowVersion input, IPrincipal principal, Action <string, string> writeError, IDataAccessStrategy <T> savingStrategy = default) { TOutput result = default; var entity = mapper.Map <T>(input); bool success = await SaveUpdatedWithOptimisticConcurrencyAsync(entity, principal, writeError, savingStrategy); if (success) { result = mapper.Map <TOutput>(entity); } return(result); }
public static byte[] EntityVersion(this IUnitOfWork uow, IHasRowVersion versionedEntity) { return((byte[])uow.PropertyValue(versionedEntity, EFCore.Version)); }
public static void EntityVersion(this IUnitOfWork uow, IHasRowVersion versionedEntity, byte[] version) { uow.PropertyValue(versionedEntity, EFCore.Version, version); }
public static byte[] EntityVersion(this IDbContext dbContext, IHasRowVersion versionedEntity) { return((byte[])dbContext.PropertyValue(versionedEntity, EFCoreShadow.Version)); }
public static void EntityVersion(this IDbContext dbContext, IHasRowVersion versionedEntity, byte[] version) { dbContext.PropertyValue(versionedEntity, EFCoreShadow.Version, version); }