示例#1
0
            public async Task EnsureEntitiesLoaded(IEnumerable <TAtypeEntityId> aEntities, IEnumerable <TBtypeEntityId> bEntities, TContext context)
            {
                var aEntitiesToLoad = aEntities.Except(_loadedAEntities.Keys, _context._atypeIdComparer).ToArray();
                var bEntitiesToLoad = bEntities.Except(_loadedBEntities.Keys, _context._btypeIdComparer).ToArray();

                if (aEntitiesToLoad.Any() || bEntitiesToLoad.Any())
                {
                    _totalProgress.NotifyLoadCount(aEntitiesToLoad.Length, bEntitiesToLoad.Length);
                    using (_totalProgress.StartARepositoryLoad())
                    {
                        AddToDictionary(_loadedAEntities, await _context._atypeRepository.Get(aEntitiesToLoad, _aLogger, context));
                    }

                    using (_totalProgress.StartBRepositoryLoad())
                    {
                        AddToDictionary(_loadedBEntities, await _context._btypeRepository.Get(bEntitiesToLoad, _bLogger, context));
                    }
                }
            }
            public async Task FillIfEmpty(ICollection <TAtypeEntityId> aEntitiesToLoad, ICollection <TBtypeEntityId> bEntitiesToLoad, TContext context)
            {
                if (_aEntities == null)
                {
                    _totalProgress.NotifyLoadCount(aEntitiesToLoad.Count, bEntitiesToLoad.Count);
                    using (_totalProgress.StartARepositoryLoad())
                    {
                        _aEntities = CreateDictionary(
                            await _context._atypeRepository.Get(aEntitiesToLoad, _aLogger, context),
                            _context._atypeIdComparer);
                    }

                    using (_totalProgress.StartBRepositoryLoad())
                    {
                        _bEntities = CreateDictionary(
                            await _context._btypeRepository.Get(bEntitiesToLoad, _bLogger, context),
                            _context._btypeIdComparer);
                    }
                }
            }