Table of Contents

Interface IQueryExecutor

Namespace
NextORM.Core
Assembly
nextorm.core.dll

Executes a prepared query command and materializes its result. The convenience overloads (parameterless ToList, Any, cancellation-only variants) live in DataContextExtensions.

public interface IQueryExecutor
Extension Methods

Methods

ExecuteScalar<TResult>(IPreparedQueryCommand<TResult>, object[]?, bool, CancellationToken)

Asynchronously executes the query and returns its scalar value.

Task<TResult?> ExecuteScalar<TResult>(IPreparedQueryCommand<TResult> preparedQueryCommand, object[]? @params, bool throwIfNull, CancellationToken cancellationToken)

Parameters

preparedQueryCommand IPreparedQueryCommand<TResult>

The compiled query to execute.

params object[]

The positional parameter values bound to the query, or null for none.

throwIfNull bool

Whether to throw when the scalar is null instead of returning it.

cancellationToken CancellationToken

Cancels execution of the query.

Returns

Task<TResult>

A task producing the scalar value, or null when none was returned.

Type Parameters

TResult

The scalar result type.

ExecuteScalar<TResult>(IPreparedQueryCommand<TResult>, ReadOnlySpan<object?>, bool)

Executes the query and returns its scalar value.

TResult? ExecuteScalar<TResult>(IPreparedQueryCommand<TResult> preparedQueryCommand, ReadOnlySpan<object?> @params, bool throwIfNull)

Parameters

preparedQueryCommand IPreparedQueryCommand<TResult>

The compiled query to execute.

params ReadOnlySpan<object>

The positional parameter values bound to the query.

throwIfNull bool

Whether to throw when the scalar is null instead of returning it.

Returns

TResult

The scalar value, or null when none was returned.

Type Parameters

TResult

The scalar result type.

FirstAsync<TResult>(IPreparedQueryCommand<TResult>, object[]?, CancellationToken)

Asynchronously returns the first result row, throwing when the query returns none.

Task<TResult> FirstAsync<TResult>(IPreparedQueryCommand<TResult> preparedQueryCommand, object[]? @params, CancellationToken cancellationToken)

Parameters

preparedQueryCommand IPreparedQueryCommand<TResult>

The compiled query to execute.

params object[]

The positional parameter values bound to the query, or null for none.

cancellationToken CancellationToken

Cancels reading of the result row.

Returns

Task<TResult>

A task producing the first result row.

Type Parameters

TResult

The result element type.

FirstOrDefaultAsync<TResult>(IPreparedQueryCommand<TResult>, object[]?, CancellationToken)

Asynchronously returns the first result row, or the default value when the query returns none.

Task<TResult?> FirstOrDefaultAsync<TResult>(IPreparedQueryCommand<TResult> preparedQueryCommand, object[]? @params, CancellationToken cancellationToken)

Parameters

preparedQueryCommand IPreparedQueryCommand<TResult>

The compiled query to execute.

params object[]

The positional parameter values bound to the query, or null for none.

cancellationToken CancellationToken

Cancels reading of the result row.

Returns

Task<TResult>

A task producing the first result row, or the default value of TResult.

Type Parameters

TResult

The result element type.

FirstOrDefault<TResult>(IPreparedQueryCommand<TResult>, ReadOnlySpan<object?>)

Returns the first result row, or the default value when the query returns none.

TResult? FirstOrDefault<TResult>(IPreparedQueryCommand<TResult> preparedQueryCommand, ReadOnlySpan<object?> @params)

Parameters

preparedQueryCommand IPreparedQueryCommand<TResult>

The compiled query to execute.

params ReadOnlySpan<object>

The positional parameter values bound to the query.

Returns

TResult

The first result row, or the default value of TResult.

Type Parameters

TResult

The result element type.

First<TResult>(IPreparedQueryCommand<TResult>, ReadOnlySpan<object?>)

Returns the first result row, throwing when the query returns none.

TResult First<TResult>(IPreparedQueryCommand<TResult> preparedQueryCommand, ReadOnlySpan<object?> @params)

Parameters

preparedQueryCommand IPreparedQueryCommand<TResult>

The compiled query to execute.

params ReadOnlySpan<object>

The positional parameter values bound to the query.

Returns

TResult

The first result row.

Type Parameters

TResult

The result element type.

SingleAsync<TResult>(IPreparedQueryCommand<TResult>, object[]?, CancellationToken)

Asynchronously returns the single result row, throwing when the query returns none or more than one.

Task<TResult> SingleAsync<TResult>(IPreparedQueryCommand<TResult> preparedQueryCommand, object[]? @params, CancellationToken cancellationToken)

Parameters

preparedQueryCommand IPreparedQueryCommand<TResult>

The compiled query to execute.

params object[]

The positional parameter values bound to the query, or null for none.

cancellationToken CancellationToken

Cancels reading of the result row.

Returns

Task<TResult>

A task producing the single result row.

Type Parameters

TResult

The result element type.

SingleOrDefaultAsync<TResult>(IPreparedQueryCommand<TResult>, object[]?, CancellationToken)

Asynchronously returns the single result row, or the default value when the query returns none.

Task<TResult?> SingleOrDefaultAsync<TResult>(IPreparedQueryCommand<TResult> preparedQueryCommand, object[]? @params, CancellationToken cancellationToken)

Parameters

preparedQueryCommand IPreparedQueryCommand<TResult>

The compiled query to execute.

params object[]

The positional parameter values bound to the query, or null for none.

cancellationToken CancellationToken

Cancels reading of the result row.

Returns

Task<TResult>

A task producing the single result row, or the default value of TResult.

Type Parameters

TResult

The result element type.

SingleOrDefault<TResult>(IPreparedQueryCommand<TResult>, ReadOnlySpan<object?>)

Returns the single result row, or the default value when the query returns none, throwing when it returns more than one.

TResult? SingleOrDefault<TResult>(IPreparedQueryCommand<TResult> preparedQueryCommand, ReadOnlySpan<object?> @params)

Parameters

preparedQueryCommand IPreparedQueryCommand<TResult>

The compiled query to execute.

params ReadOnlySpan<object>

The positional parameter values bound to the query.

Returns

TResult

The single result row, or the default value of TResult.

Type Parameters

TResult

The result element type.

Single<TResult>(IPreparedQueryCommand<TResult>, ReadOnlySpan<object?>)

Returns the single result row, throwing when the query returns none or more than one.

TResult Single<TResult>(IPreparedQueryCommand<TResult> preparedQueryCommand, ReadOnlySpan<object?> @params)

Parameters

preparedQueryCommand IPreparedQueryCommand<TResult>

The compiled query to execute.

params ReadOnlySpan<object>

The positional parameter values bound to the query.

Returns

TResult

The single result row.

Type Parameters

TResult

The result element type.

ToListAsync<TResult>(IPreparedQueryCommand<TResult>, object[]?, CancellationToken)

Asynchronously materializes all result rows into a list.

Task<List<TResult>> ToListAsync<TResult>(IPreparedQueryCommand<TResult> preparedQueryCommand, object[]? @params, CancellationToken cancellationToken)

Parameters

preparedQueryCommand IPreparedQueryCommand<TResult>

The compiled query to execute.

params object[]

The positional parameter values bound to the query, or null for none.

cancellationToken CancellationToken

Cancels reading of the result rows.

Returns

Task<List<TResult>>

A task producing the materialized result rows.

Type Parameters

TResult

The result element type.

ToList<TResult>(IPreparedQueryCommand<TResult>, ReadOnlySpan<object?>)

Materializes all result rows into a list.

List<TResult> ToList<TResult>(IPreparedQueryCommand<TResult> preparedQueryCommand, ReadOnlySpan<object?> @params)

Parameters

preparedQueryCommand IPreparedQueryCommand<TResult>

The compiled query to execute.

params ReadOnlySpan<object>

The positional parameter values bound to the query.

Returns

List<TResult>

The materialized result rows.

Type Parameters

TResult

The result element type.