Exemple #1
0
        public async Task <TResult> ExecuteAsync <TResult>(IEnumerable <Query> queries, QueryType queryType, CancellationToken cancellationToken = default)
        {
            if (queries == null)
            {
                throw new ArgumentNullException(nameof(queries));
            }

            if (this.Options.Store == null)
            {
                throw new InvalidOperationException("No schema builder found.");
            }

            ISchema     schema = this.Options.Store.GetSchema(typeof(TResult));
            QueryBuffer buffer = new QueryBuffer(schema, queryType);

            await using IAsyncSession connection = this.Options.GetAsyncSession();

            foreach (IBatch batch in this.FilterBatches(queries))
            {
                await foreach (DbDataReader dataReader in connection.ExecuteAsync(batch, cancellationToken).ConfigureAwait(false))
                {
                    await buffer.InsertAsync(dataReader, cancellationToken).ConfigureAwait(false);
                }
            }

            return((TResult)buffer.Commit());
        }
Exemple #2
0
        public TResult Execute <TResult>(IEnumerable <Query> queries, QueryType queryType)
        {
            if (queries == null)
            {
                throw new ArgumentNullException(nameof(queries));
            }

            if (this.Options.Store == null)
            {
                throw new InvalidOperationException("No schema store found.");
            }

            ISchema     schema = this.Options.Store.GetSchema(typeof(TResult));
            QueryBuffer buffer = new QueryBuffer(schema, queryType);

            using ISyncSession connection = this.Options.GetSyncSession();

            foreach (IBatch batch in this.FilterBatches(queries))
            {
                foreach (IDataReader dataReader in connection.Execute(batch))
                {
                    buffer.Insert(dataReader);
                }
            }

            return((TResult)buffer.Commit());
        }