Beispiel #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);
                }
            }
        }
        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();
                }
            }
        }
Beispiel #3
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);
                }
            }
        }