Skip to content

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

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 TRow ById<TRow>(this IDbConnection connection, object id)
    where TRow : class, IRow, IIdRow, new()
parameter description
TRow The type of the row.
connection The connection.
id The identifier.

Return Value

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.ById<TRow> method (2 of 2)

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 TRow ById<TRow>(this IDbConnection connection, object id, Action<SqlQuery> editQuery)
    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.

Return Value

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