Пример #1
0
        public async Task <List <T> > ToListAsync(CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            if (!HasValue)
            {
#if EF6
                if (Query.Context.IsInMemoryEffortQueryContext())
                {
                    OwnerBatch.ExecuteQueries();
                }
                else
                {
                    await OwnerBatch.ExecuteQueriesAsync(cancellationToken).ConfigureAwait(false);
                }
#else
                await OwnerBatch.ExecuteQueriesAsync(cancellationToken).ConfigureAwait(false);
#endif
            }

            if (_result == null)
            {
                return(new List <T>());
            }

            using (var enumerator = _result.GetEnumerator())
            {
                var list = new List <T>();
                while (enumerator.MoveNext())
                {
                    list.Add(enumerator.Current);
                }
                return(list);
            }
        }
Пример #2
0
        /// <summary>Gets the enumerator of the query future.</summary>
        /// <returns>The enumerator of the query future.</returns>
        public IEnumerator <T> GetEnumerator()
        {
            if (!HasValue)
            {
                OwnerBatch.ExecuteQueries();
            }

            return(_result.GetEnumerator());
        }
Пример #3
0
        /// <summary>Gets the enumerator of the query future.</summary>
        /// <returns>The enumerator of the query future.</returns>
        public IEnumerator <T> GetEnumerator()
        {
            if (!HasValue)
            {
                OwnerBatch.ExecuteQueries();
            }

            if (_result == null)
            {
                return(new List <T>().GetEnumerator());
            }

            return(_result.GetEnumerator());
        }
        /// <summary>Gets the value of the future query.</summary>
        /// <value>The value of the future query.</value>
        public async Task <TResult> ValueAsync(CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            if (!HasValue)
            {
#if EF6
                if (Query.Context.IsInMemoryEffortQueryContext())
                {
                    OwnerBatch.ExecuteQueries();
                }
                else
                {
                    await OwnerBatch.ExecuteQueriesAsync(cancellationToken).ConfigureAwait(false);
                }
#else
                await OwnerBatch.ExecuteQueriesAsync(cancellationToken).ConfigureAwait(false);
#endif
            }

            return(_result);
        }