Table of Contents

Class DataRequestBase<TConnection, TModel>

Namespace
Excalibur.Data
Assembly
Excalibur.Data.Abstractions.dll

Serves as the base class for implementing database requests with a specific connection type and return model.

public abstract class DataRequestBase<TConnection, TModel> : IDataRequest<TConnection, TModel>, IDataRequest

Type Parameters

TConnection

The type of the database connection.

TModel

The type of the model to be returned by the request.

Inheritance
DataRequestBase<TConnection, TModel>
Implements
IDataRequest<TConnection, TModel>
Derived
Inherited Members
Extension Methods

Properties

Command

Gets the command definition used for executing the request.

public CommandDefinition Command { get; protected init; }

Property Value

CommandDefinition

The command definition used for executing the request.

CorrelationId

Gets the optional correlation identifier for tracking related requests.

public string? CorrelationId { get; set; }

Property Value

string

The optional correlation identifier for tracking related requests.

CreatedAt

Gets the timestamp when the request was created.

public DateTimeOffset CreatedAt { get; }

Property Value

DateTimeOffset

The timestamp when the request was created.

Metadata

Gets additional metadata associated with the request.

public IDictionary<string, object>? Metadata { get; set; }

Property Value

IDictionary<string, object>

Additional metadata associated with the request.

Parameters

Gets the parameters associated with the request.

public DynamicParameters Parameters { get; }

Property Value

DynamicParameters

The parameters associated with the request.

RequestId

Gets the unique request identifier.

public string RequestId { get; }

Property Value

string

The unique request identifier.

RequestType

Gets the request type name.

public string RequestType { get; }

Property Value

string

The request type name.

ResolveAsync

Gets the function responsible for resolving the request result using the provided connection.

public Func<TConnection, Task<TModel>> ResolveAsync { get; protected init; }

Property Value

Func<TConnection, Task<TModel>>

The function responsible for resolving the request result using the provided connection.

Methods

CreateCommand(string, DynamicParameters?, IDbTransaction?, int?, CommandType?, CancellationToken)

Creates a command definition for the request.

protected CommandDefinition CreateCommand(string commandText, DynamicParameters? parameters = null, IDbTransaction? transaction = null, int? commandTimeout = null, CommandType? commandType = null, CancellationToken cancellationToken = default)

Parameters

commandText string

The SQL command text.

parameters DynamicParameters

The parameters for the command (optional).

transaction IDbTransaction

The transaction for this command to participate in.

commandTimeout int?

The timeout (in seconds) for this command.

commandType CommandType?

The CommandType for this command.

cancellationToken CancellationToken

The cancellation token for this command.

Returns

CommandDefinition

A Dapper.CommandDefinition instance representing the request.

ExecuteNonQueryAsync(IDbConnection, Action<DbCommand>)

Executes this request without runtime parameter discovery or generated command initialization.

protected Task<int> ExecuteNonQueryAsync(IDbConnection connection, Action<DbCommand> bind)

Parameters

connection IDbConnection

The existing provider connection.

bind Action<DbCommand>

Binds the operation's known parameters from their current request values.

Returns

Task<int>

The affected row count.

Remarks

The request's command text, transaction, timeout, command type and cancellation token are preserved.

ExecuteScalarAsync(IDbConnection, Action<DbCommand>)

Reads this request's scalar result without runtime parameter discovery.

protected Task<object?> ExecuteScalarAsync(IDbConnection connection, Action<DbCommand> bind)

Parameters

connection IDbConnection

The existing provider connection.

bind Action<DbCommand>

Binds the operation's known parameters from their current request values.

Returns

Task<object>

The provider's first-column scalar value.

ReadRowsAsync<TRow>(IDbConnection, Action<DbCommand>, Func<DbDataReader, TRow>)

Buffers rows with an explicit ordinal projection instead of runtime row mapping.

protected Task<IEnumerable<TRow>> ReadRowsAsync<TRow>(IDbConnection connection, Action<DbCommand> bind, Func<DbDataReader, TRow> materialize)

Parameters

connection IDbConnection

The existing provider connection.

bind Action<DbCommand>

Binds the operation's known parameters from their current request values.

materialize Func<DbDataReader, TRow>

Reads one current row using the operation's fixed projection.

Returns

Task<IEnumerable<TRow>>

The fully buffered rows after reader cleanup.

Type Parameters

TRow

The operation's statically known row type.

Remarks

A borrowed open connection and transaction remain caller-owned. A connection opened for this request is closed afterward.