Esempio n. 1
0
        protected virtual async Task EnsureIsLoadedAsync(CancellationToken cancellationToken = default)
        {
            if (_list == null)
            {
                if (SourceQuery is not IAsyncEnumerable <T> )
                {
                    // Don't call EF's async extension methods if query is not IAsyncEnumerable<T>
                    EnsureIsLoaded();
                    return;
                }

                if (_totalCount == null)
                {
                    _totalCount = await SourceQuery.CountAsync(cancellationToken);
                }

                if (_queryIsPagedAlready)
                {
                    _list = await SourceQuery.ToListAsync(cancellationToken);
                }
                else
                {
                    _list = await ApplyPaging().ToListAsync(cancellationToken);
                }
            }
        }
Esempio n. 2
0
        public async Task <int> GetTotalCountAsync()
        {
            if (!_totalCount.HasValue)
            {
                _totalCount = await SourceQuery.CountAsync();
            }

            return(_totalCount.Value);
        }
        private async Task EnsureIsLoadedAsync()
        {
            if (_list == null)
            {
                if (_totalCount == null)
                {
                    _totalCount = await SourceQuery.CountAsync();
                }

                if (_queryIsPagedAlready)
                {
                    _list = await SourceQuery.ToListAsync();
                }
                else
                {
                    _list = await ApplyPaging(SourceQuery).ToListAsync();
                }
            }
        }
Esempio n. 4
0
        private async Task EnsureIsLoadedAsync(CancellationToken cancellationToken = default)
        {
            if (_list == null)
            {
                if (_totalCount == null)
                {
                    _totalCount = await SourceQuery.CountAsync(cancellationToken);
                }

                if (_queryIsPagedAlready)
                {
                    _list = await SourceQuery.ToListAsync(cancellationToken);
                }
                else
                {
                    _list = await ApplyPaging(SourceQuery).ToListAsync(cancellationToken);
                }
            }
        }