internal override void Execute(IDeleteCore core) { var sql = $"UPDATE {TableName} SET {CleanField} = NULL " + WhereStatment; core.AddExcuteOperation(String.Format("Очищаем ссылки в таблице {0}", TableName)); core.ExecuteSql(sql, ItemId); }
internal override void Execute(IDeleteCore core) { core.AddExcuteOperation(String.Format("Очищаем коллекции в {0}", DomainHelper.GetSubjectNames(RemoveInClassType).NominativePlural)); var collectionProp = RemoveInClassType.GetProperty(CollectionName); var removeMethod = String.IsNullOrEmpty(RemoveMethodName) ? null : RemoveInClassType.GetMethod(RemoveMethodName); foreach (var item in RemoveInItems) { logger.Debug("Удаляем {2} из коллекции {0} в {1}...", CollectionName, item.Title, RemovingEntity.Title); if (removeMethod != null) { if (item.Entity is IBusinessObject) { (item.Entity as IBusinessObject).UoW = core.UoW; } removeMethod.Invoke(item.Entity, new object[] { RemovingEntity.Entity }); } else { var collection = (IList)collectionProp.GetValue(item.Entity, null); collection.Remove(RemovingEntity.Entity); } core.UoW.TrySave(item.Entity); } }
internal override void Execute(IDeleteCore core, CancellationToken cancellation) { if (cancellation.IsCancellationRequested) { return; } ChildBeforeOperations.ForEach(o => o.Execute(core, cancellation)); if (cancellation.IsCancellationRequested) { return; } core.AddExcuteOperation(String.Format("Удаляем {0}", DomainHelper.GetSubjectNames(DeletingItems[0].Entity)?.NominativePlural)); foreach (var item in DeletingItems) { if (cancellation.IsCancellationRequested) { return; } logger.Debug($"Удаляем [{item.Id}] {item.Title}..."); core.UoW.TryDelete(item.Entity); } if (cancellation.IsCancellationRequested) { return; } ChildAfterOperations.ForEach(o => o.Execute(core, cancellation)); }
internal override void Execute(IDeleteCore core, CancellationToken cancellation) { if (cancellation.IsCancellationRequested) { return; } ChildBeforeOperations.ForEach(o => o.Execute(core, cancellation)); if (cancellation.IsCancellationRequested) { return; } core.AddExcuteOperation(String.Format("Удаляем из таблицы {0}", TableName)); core.ExecuteSql( String.Format("DELETE FROM {0} {1}", TableName, WhereStatment), ItemId); if (cancellation.IsCancellationRequested) { return; } ChildAfterOperations.ForEach(o => o.Execute(core, cancellation)); }
internal override void Execute(IDeleteCore core) { ChildBeforeOperations.ForEach(o => o.Execute(core)); core.AddExcuteOperation(String.Format("Удаляем из таблицы {0}", TableName)); core.ExecuteSql( String.Format("DELETE FROM {0} {1}", TableName, WhereStatment), ItemId); ChildAfterOperations.ForEach(o => o.Execute(core)); }
internal override void Execute(IDeleteCore core) { core.AddExcuteOperation(String.Format("Очищаем ссылки в {0}", DomainHelper.GetSubjectNames(EntityType).NominativePlural)); var propertyCache = EntityType.GetProperty(PropertyName); foreach (var item in ClearingItems) { logger.Debug("Очищаем свойство {0} в {1}...", PropertyName, item.Title); propertyCache.SetValue(item.Entity, null, null); core.UoW.TrySave(item.Entity); } }
internal override void Execute(IDeleteCore core, CancellationToken cancellation) { if (cancellation.IsCancellationRequested) { return; } var sql = $"UPDATE {TableName} SET {CleanField} = NULL " + WhereStatment; core.AddExcuteOperation(String.Format("Очищаем ссылки в таблице {0}", TableName)); core.ExecuteSql(sql, ItemId); }
internal override void Execute(IDeleteCore core) { ChildBeforeOperations.ForEach(o => o.Execute(core)); core.AddExcuteOperation(String.Format("Удаляем {0}", DomainHelper.GetSubjectNames(DeletingItems[0].Entity).NominativePlural)); foreach (var item in DeletingItems) { logger.Debug("Удаляем {0}...", item.Title); core.UoW.TryDelete(item.Entity); } ChildAfterOperations.ForEach(o => o.Execute(core)); }