ExecuteScalarAs Method
Definition
ExecuteScalarAs<TResult>(DataStatement, Action<ObjectFormattingOptions>)
Executes the command statement, and attempts to convert the first column of the first row in the result set to the specified TResult.
Additional columns or rows are ignored.
public virtual TResult ExecuteScalarAs<TResult>(DataStatement statement, Action<ObjectFormattingOptions> setup = null)
Parameters
statementDataStatementThe command statement to execute.
setupAction<ObjectFormattingOptions>The ObjectFormattingOptions which may be configured.
Returns
- TResult
The first column of the first row in the result from
statementasTResult.
Type Parameters
TResultThe type of the return value.
Remarks
This method uses InvariantCulture when casting the first column of the first row in the result from statement.
Exceptions
- AggregateException
The first column of the first row in the result set could not be converted.
- See Also