Skip to content

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

namespace: Serenity.Data   assemblySerenity.Net.Services

Asynchronously finds an entity by its ID value. 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> ByIdAsync<TRow>(this IDbConnection connection, object id, 
    CancellationToken cancellationToken = default(CancellationToken))
    where TRow : class, IRow, IIdRow, new()
parameter description
TRow The type of the row.
connection The connection.
id The identifier.
cancellationToken The cancellation token.

Return Value

A task representing the asynchronous operation. The task result is the entity with the given ID.

Exceptions

exception condition
ValidationError Record with the specified ID is not found.
InvalidOperationException Multiple records with the ID found.

See Also


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

namespace: Serenity.Data   assemblySerenity.Net.Services

Asynchronously finds an entity by its ID value. This method does not select any fields by default and allows you to edit the query to select fields you want.

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

Return Value

A task representing the asynchronous operation. The task result is the entity with the given ID.

Exceptions

exception condition
ValidationError Record with the specified ID is not found.
InvalidOperationException Multiple records with the ID found.

See Also