public async Task ValidateAsync(string entityDefinitionCode, int entityId, IExecutionContext executionContext)
        {
            if (string.IsNullOrWhiteSpace(entityDefinitionCode))
            {
                throw new ArgumentEmptyException(nameof(entityDefinitionCode));
            }
            if (entityId < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(entityDefinitionCode), nameof(entityId) + "must be a positive integer.");
            }
            if (executionContext == null)
            {
                throw new ArgumentEmptyException(nameof(executionContext));
            }

            var entityDefinition     = _entityDefinitionRepository.GetRequiredByCode(entityDefinitionCode);
            var requiredDependencies = await _queryExecutor.ExecuteAsync(new GetEntityDependencySummaryByRelatedEntityIdQuery()
            {
                EntityDefinitionCode = entityDefinition.EntityDefinitionCode,
                EntityId             = entityId,
                ExcludeDeletable     = true
            }, executionContext);

            RequiredDependencyConstaintViolationException.ThrowIfCannotDelete(entityDefinition, requiredDependencies);
        }
        private async Task ValidateDependencies(string entityDefinitionCode, ICollection <int> entityIds, IExecutionContext executionContext)
        {
            if (!entityIds.Any())
            {
                return;
            }

            var requiredDependencies = await _queryExecutor.ExecuteAsync(new GetEntityDependencySummaryByRelatedEntityIdRangeQuery()
            {
                EntityDefinitionCode = entityDefinitionCode,
                EntityIds            = entityIds,
                ExcludeDeletable     = true
            }, executionContext);

            RequiredDependencyConstaintViolationException.ThrowIfCannotDelete(DIRECTORY_ENTITY_DEFINITION, requiredDependencies);
        }