public async Task <IList <WorkflowInstanceEntity> > ListByDefinitionId(string definitionId)
        {
            var result = await _repository.ListByDefinitionIdAsync(definitionId);

            if (!result.Any())
            {
                return(new List <WorkflowInstanceEntity>());
            }
            var ids        = result.Select(a => a.Id).ToList();
            var activities = await _activityInstanceRepository.ListByWorkflowInstanceIdsAsync(ids);

            var blockingActivities = await _blockingActivityRepository.ListByWorkflowInstanceIdsAsync(ids);

            foreach (var item in result)
            {
                item.Activities         = activities.Where(a => a.WorkflowInstance == item.Id).ToList();
                item.BlockingActivities = blockingActivities.Where(a => a.WorkflowInstance == item.Id).ToList();
            }
            return(result);
        }