示例#1
0
        public IEnumerable <T> Read <T>()
        {
            ISchema schema = this.Store.GetSchema(typeof(IList <T>));
            EnumerateFactory <T> reader = QueryCache.GetEnumerateFactory <T>(schema, this.syncReader);

            while (this.syncReader.Read())
            {
                yield return(reader(this.syncReader));
            }
        }
示例#2
0
        public async IAsyncEnumerable <T> ReadAsync <T>([EnumeratorCancellation] CancellationToken cancellationToken = default)
        {
            if (this.asyncReader == null)
            {
                throw new QueryException("Async not available. To use async operations, instantiate with a DbDataReader instance.");
            }

            ISchema schema = this.Store.GetSchema(typeof(IList <T>));
            EnumerateFactory <T> reader = QueryCache.GetEnumerateFactory <T>(schema, this.asyncReader);

            while (await this.asyncReader.ReadAsync(cancellationToken).ConfigureAwait(false))
            {
                yield return(reader(this.asyncReader));
            }
        }