Пример #1
0
        /// <summary>
        /// Builds out a LinqHandlerBuilder for this MartenQueryable<T>
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
        internal LinqHandlerBuilder BuildLinqHandler(Expression expression)
        {
            var builder = new LinqHandlerBuilder(this, _session, expression);

            builder.BuildDatabaseStatement();
            return(builder);
        }
Пример #2
0
        public Task StreamMany(Expression expression, Stream destination, CancellationToken token)
        {
            var builder = new LinqHandlerBuilder(this, _session, expression);

            builder.BuildDatabaseStatement();

            var command = builder.TopStatement.BuildCommand();

            return(_session.Database.StreamMany(command, destination, token));
        }
Пример #3
0
        public Task <bool> StreamOne(Expression expression, Stream destination, CancellationToken token)
        {
            var builder = new LinqHandlerBuilder(this, _session, expression);

            builder.BuildDatabaseStatement();

            var statement = builder.TopStatement;

            statement.Current().Limit = 1;
            var command = statement.BuildCommand();

            return(_session.StreamOne(command, destination, token));
        }
Пример #4
0
        public async Task <bool> StreamOne(Expression expression, Stream destination, CancellationToken token)
        {
            var builder = new LinqHandlerBuilder(this, _session, expression);

            builder.BuildDatabaseStatement();

            await ensureStorageExistsAsync(builder, token).ConfigureAwait(false);

            var statement = builder.TopStatement;

            statement.Current().Limit = 1;
            var command = statement.BuildCommand();

            return(await _session.StreamOne(command, destination, token).ConfigureAwait(false));
        }
Пример #5
0
        public async IAsyncEnumerable <T> ExecuteAsyncEnumerable <T>(Expression expression, [EnumeratorCancellation] CancellationToken token)
        {
            var builder = new LinqHandlerBuilder(this, _session, expression);

            builder.BuildDatabaseStatement();

            var selector  = (ISelector <T>)builder.CurrentStatement.SelectClause.BuildSelector(_session);
            var statement = builder.TopStatement;

            var cmd = _session.BuildCommand(statement);

            using var reader = await _session.ExecuteReaderAsync(cmd, token).ConfigureAwait(false);

            while (await reader.ReadAsync(token).ConfigureAwait(false))
            {
                yield return(await selector.ResolveAsync(reader, token).ConfigureAwait(false));
            }
        }