internal static void Delete(int id) { using (var scope = new QPConnectionScope()) { if (QPContext.DatabaseType == DatabaseType.SqlServer) { ChangeDeleteBindingsTriggerState(false); } var bindings = QPContext.EFContext.ContentWorkflowBindSet.Where(n => n.WorkflowId == id).ToArray(); DefaultRepository.SimpleDeleteBulk(bindings); var bindings2 = QPContext.EFContext.ArticleWorkflowBindSet.Where(n => n.WorkflowId == id).ToArray(); DefaultRepository.SimpleDeleteBulk(bindings2); var waits = QPContext.EFContext.WaitingForApprovalSet.Include(n => n.Article.WorkflowBinding) .Where(n => n.Article.WorkflowBinding.WorkflowId == id).ToArray(); DefaultRepository.SimpleDeleteBulk(waits); DefaultRepository.Delete <WorkflowDAL>(id); if (QPContext.DatabaseType == DatabaseType.SqlServer) { ChangeDeleteBindingsTriggerState(true); } } }
internal static void RemoveUserQuerySourcesInfo(Content uqVirtualContent) { var virtualContentId = uqVirtualContent.Id; var context = QPContext.EFContext; var recToRemove = context.UserQueryContentsSet.Where(u => u.VirtualContentId == virtualContentId).ToArray(); DefaultRepository.SimpleDeleteBulk(recToRemove, context); }
/// <summary> /// Сохранить записи в таблице union_contents /// </summary> internal static void RecreateUnionSourcesInfo(Content virtualContent, IEnumerable <int> unionSourceContentIDs) { try { ChangeUnionContentTriggerState(false); var virtualContentId = virtualContent.Id; var context = QPContext.EFContext; var recToRemove = context.UnionContentsSet.Where(u => u.VirtualContentId == virtualContentId).ToArray(); DefaultRepository.SimpleDeleteBulk(recToRemove, context); DefaultRepository.SimpleSaveBulk(unionSourceContentIDs.Select(id => new UnionContentsDAL { VirtualContentId = virtualContentId, UnionContentId = id })); } finally { ChangeUnionContentTriggerState(true); } }
internal static void DeleteAppSettings() { var context = QPContext.EFContext; DefaultRepository.SimpleDeleteBulk(context.AppSettingsSet.ToList(), context); }
internal static ContentConstraint Update(ContentConstraint constraint) { if (constraint == null) { throw new ArgumentNullException(nameof(constraint)); } if (constraint.IsNew) { throw new ArgumentException("Метод вызван для несуществующего в БД ContentConstraint"); } // если нет правил, то удалить ограничение if (constraint.Rules == null || !constraint.Rules.Any()) { Delete(constraint); return(null); } using (var scope = new QPConnectionScope()) { try { if (QPContext.DatabaseType == DatabaseType.SqlServer) { ChangeContentIndexesTriggerState(scope.DbConnection, false); } var context = QPContext.EFContext; var oldConstraintDal = context.ContentConstraintSet.Include(n => n.Rules) .Single(d => d.Id == constraint.Id); Common.DropComplexIndex(scope.DbConnection, oldConstraintDal); // удалить все правила которые уже есть DefaultRepository.SimpleDeleteBulk(oldConstraintDal.Rules.ToArray(), context); // создать новые записи для правил foreach (var rule in constraint.Rules) { rule.ConstraintId = constraint.Id; } var newDalList = MapperFacade.ContentConstraintRuleMapper.GetDalList(constraint.Rules.ToList()); var list = DefaultRepository.SimpleSaveBulk(newDalList.AsEnumerable()).ToList(); constraint.Rules = MapperFacade.ContentConstraintRuleMapper.GetBizList(list).ToArray(); if (constraint.IsComplex) { var dal = MapperFacade.ContentConstraintMapper.GetDalObject(constraint); Common.CreateComplexIndex(QPContext.EFContext, scope.DbConnection, dal); } } finally { if (QPContext.DatabaseType == DatabaseType.SqlServer) { ChangeContentIndexesTriggerState(scope.DbConnection, true); } } } return(constraint); }