Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 3
0
        /// <summary>Gets the enumerator.</summary>
        /// <returns>The enumerator.</returns>
        public IEnumerator <T> GetEnumerator()
        {
            if (!HasResult)
            {
                OwnerBatch.Execute();
            }

            return((Result as IEnumerable <T>).GetEnumerator());
        }
Ejemplo n.º 4
0
        /// <summary>Gets the value of the future query.</summary>
        /// <value>The value of the future query.</value>
        public async Task <TResult> ValueAsync()
        {
            if (!HasValue)
            {
                await OwnerBatch.ExecuteQueriesAsync().ConfigureAwait(false);
            }

            return(_result);
        }
Ejemplo n.º 5
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());
        }
        public async Task <T> FirstOrDefaultAsync()
        {
            if (!HasValue)
            {
                await OwnerBatch.ExecuteQueriesAsync().ConfigureAwait(false);
            }

            if (_result == null)
            {
                return(default(T));
            }

            using (var enumerator = _result.GetEnumerator())
            {
                enumerator.MoveNext();
                return(enumerator.Current);
            }
        }
        /// <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);
        }
Ejemplo n.º 8
0
        public async Task <List <T> > ToListAsync()
        {
            if (!HasValue)
            {
                await OwnerBatch.ExecuteQueriesAsync().ConfigureAwait(false);
            }

            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);
            }
        }