Method SingleAsync
| Improve this Doc View SourceSingleAsync<TEntity, T>(DbSet<TEntity>, Func<TEntity, T>, CancellationToken)
Returns the only value of specified database recordset column; this method throws an exception if no record or more than one record exists.
Declaration
public static Task<T> SingleAsync<TEntity, T>(this DbSet<TEntity> dbSet, Func<TEntity, T> getColumn, CancellationToken ct = default(CancellationToken))
where TEntity : class, IEntity, new()
where T : Column, IColumn<DbReader>, new()
Parameters
| Type | Name | Description |
|---|---|---|
| DbSet<TEntity> | dbSet | The database recordset. |
| System.Func<TEntity, T> | getColumn | Delegate to return the column from Database recordset. |
| System.Threading.CancellationToken | ct | The async cancellation token. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<T> | The only value. |
Type Parameters
| Name | Description |
|---|---|
| TEntity | The entity type of database recordset. |
| T | The data type of the column. |