querySingle method
Future<Map<String, Object?> >
querySingle(
- String sql, {
- Object parameters = const <String, Object?>{},
- MssqlQueryOptions options = MssqlQueryOptions.defaults,
- Duration? timeout,
- MssqlCancellationToken? cancellationToken,
inherited
Exactly one row, as a map. More than one is an error, not a choice.
Implementation
Future<Map<String, Object?>> querySingle(
String sql, {
Object parameters = const <String, Object?>{},
MssqlQueryOptions options = MssqlQueryOptions.defaults,
Duration? timeout,
MssqlCancellationToken? cancellationToken,
}) async {
final rows = await queryRows(
sql,
parameters: parameters,
options: options.limitedTo(2),
timeout: timeout,
cancellationToken: cancellationToken,
);
if (rows.isEmpty) throw const MssqlNoRowsException();
if (rows.length > 1) throw const MssqlMultipleRowsException();
return rows.single;
}