Skip to content

EntityConnectionExtensions.SingleAsync<TRow> method (1 of 2)

Asynchronously finds a single entity, allowing caller to edit the criteria and set of fields to load through a editQuery callback.

public static Task<TRow> SingleAsync<TRow>(this IDbConnection connection, 
    Action<SqlQuery> editQuery, CancellationToken cancellationToken = default)
    where TRow : class, IRow, new()
parameter description
TRow The type of the row.
connection The connection.
editQuery The callback to edit query.
cancellationToken The cancellation token.

Return Value

A task representing the asynchronous operation. The task result is the single entity matching the criteria set by editQuery.

Exceptions

exception condition
ValidationError No records matching the specified criteria.
InvalidOperationException Multiple records matching the specified criteria.

See Also


EntityConnectionExtensions.SingleAsync<TRow> method (2 of 2)

Asynchronously finds a single entity matching the specified criteria. This method selects only the table fields, and no foreign / calculated fields. Use other overloads if you want to select different set of fields.

public static Task<TRow> SingleAsync<TRow>(this IDbConnection connection, ICriteria? where, 
    CancellationToken cancellationToken = default)
    where TRow : class, IRow, new()
parameter description
TRow The type of the row.
connection The connection.
where The where criteria.
cancellationToken The cancellation token.

Return Value

A task representing the asynchronous operation. The task result is the single entity matching the specified criteria.

Exceptions

exception condition
ValidationError No matching records found.
InvalidOperationException Multiple records matching the specified criteria.

See Also