Exemple #1
0
        public async ValueTask <int> ExecuteTasks(IReadOnlyCollection <GraphContainer> containers, bool skipPersist,
                                                  bool isAsync, CancellationToken token)
        {
            var batchExecuted = 0;

            try {
                var rootEntityContainers = containers
                                           .Where(container => container.RootEntityContainer != null)
                                           .Select(container => container.RootEntityContainer);
                foreach (var container in rootEntityContainers)
                {
                    AddTask(container);
                }

                RegisterAllEntityGroupTasks();
                RegisterAllEntitySetTasks(containers);

                var isExecuted = isAsync
          ? await manager.Owner.Session.ExecuteInternalDelayedQueriesAsync(skipPersist, token).ConfigureAwait(false)
          : manager.Owner.Session.ExecuteInternalDelayedQueries(skipPersist);

                batchExecuted += isExecuted ? 1 : 0;

                UpdateCacheFromAllEntityGroupTasks();
                UpdateCacheFromAllEntitySetTasks(containers);

                tasks.Clear();

                var referencedEntityContainers = containers
                                                 .Select(container => container.ReferencedEntityContainers)
                                                 .Where(referencedEntityPrefetchContainers => referencedEntityPrefetchContainers != null)
                                                 .SelectMany(referencedEntityPrefetchContainers => referencedEntityPrefetchContainers);
                foreach (var container in referencedEntityContainers)
                {
                    AddTask(container);
                }

                if (tasks.Count == 0)
                {
                    return(batchExecuted);
                }

                RegisterAllEntityGroupTasks();

                isExecuted = isAsync
          ? await manager.Owner.Session.ExecuteInternalDelayedQueriesAsync(skipPersist, token).ConfigureAwait(false)
          : manager.Owner.Session.ExecuteInternalDelayedQueries(skipPersist);

                batchExecuted += isExecuted ? 1 : 0;

                UpdateCacheFromAllEntityGroupTasks();
                return(batchExecuted);
            }
            finally {
                tasks.Clear();
                foundKeys.Clear();
            }
        }
Exemple #2
0
        public int ExecuteTasks(IEnumerable <GraphContainer> containers, bool skipPersist)
        {
            var batchExecuted = 0;

            try {
                var rootEntityContainers = containers
                                           .Where(container => container.RootEntityContainer != null)
                                           .Select(container => container.RootEntityContainer);
                foreach (var container in rootEntityContainers)
                {
                    AddTask(container);
                }
                RegisterAllEntityGroupTasks();
                RegisterAllEntitySetTasks(containers);

                batchExecuted += manager.Owner.Session.ExecuteInternalDelayedQueries(skipPersist) ? 1 : 0;
                UpdateCacheFromAllEntityGroupTasks();
                UpdateCacheFromAllEntitySetTasks(containers);

                tasks.Clear();

                var referencedEntityContainers = containers
                                                 .Select(container => container.ReferencedEntityContainers)
                                                 .Where(referencedEntityPrefetchContainers => referencedEntityPrefetchContainers != null)
                                                 .SelectMany(referencedEntityPrefetchContainers => referencedEntityPrefetchContainers);
                foreach (var container in referencedEntityContainers)
                {
                    AddTask(container);
                }

                if (tasks.Count == 0)
                {
                    return(batchExecuted);
                }
                RegisterAllEntityGroupTasks();

                batchExecuted += manager.Owner.Session.ExecuteInternalDelayedQueries(skipPersist) ? 1 : 0;
                UpdateCacheFromAllEntityGroupTasks();
                return(batchExecuted);
            }
            finally {
                tasks.Clear();
                foundKeys.Clear();
            }
        }
 public void CancelTasks()
 {
     referenceContainer = null;
     graphContainers.Clear();
 }