EntityConnectionExtensions.TryById<TRow> method (1 of 2)
namespace: Serenity.Data assembly: Serenity.Net.Entity
Tries to 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 TryById<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 given ID, or null if not found
Exceptions
exception | condition |
---|---|
InvalidOperationException | Multiple records with the ID found |
See Also
- class TRow
- interface IRow
- interface IIdRow
- class EntityConnectionExtensions
EntityConnectionExtensions.TryById<TRow> method (2 of 2)
namespace: Serenity.Data assembly: Serenity.Net.Entity
Tries to find 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 TryById<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 given ID, or null if not found
Exceptions
exception | condition |
---|---|
InvalidOperationException | Multiple records with the ID found |
See Also
- class TRow
- class SqlQuery
- interface IRow
- interface IIdRow
- class EntityConnectionExtensions