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