We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hey, found an issue regarding the null safety on return type of OrDefault methods on IDapperSqlBuilderExtensions as these methods can return null.
OrDefault
IDapperSqlBuilderExtensions
The FirstOrDefault/SingleOrDefault extension methods return non-nullable types while using the Dapper methods that return a nullable generic type.
FirstOrDefault
SingleOrDefault
Dapper:
public static Task<T?> QueryFirstOrDefaultAsync<T>(this IDbConnection cnn, string sql, object? param = null, IDbTransaction? transaction = null, int? commandTimeout = null, CommandType? commandType = null) => QueryRowAsync<T?>(cnn, Row.FirstOrDefault, typeof(T), new CommandDefinition(sql, param, transaction, commandTimeout, commandType, CommandFlags.None, default))
InterpolatedSql.Dapper: IDapperSqlBuilderExtensions.cs
IDapperSqlBuilderExtensions.cs
public static T QueryFirstOrDefault<T>(this IDapperSqlBuilder builder, IDbTransaction? transaction = null, int? commandTimeout = null, CommandType? commandType = null) { var command = builder.Build(); return command.DbConnection.QueryFirstOrDefault<T>(sql: command.Sql, param: ParametersDictionary.LoadFrom(command), transaction: transaction, commandTimeout: commandTimeout, commandType: commandType); }
Adding a nullable return type would solve the issue
public static T? QueryFirstOrDefault<T>(this IDapperSqlBuilder builder, IDbTransaction? transaction = null, int? commandTimeout = null, CommandType? commandType = null) { var command = builder.Build(); return command.DbConnection.QueryFirstOrDefault<T>(sql: command.Sql, param: ParametersDictionary.LoadFrom(command), transaction: transaction, commandTimeout: commandTimeout, commandType: commandType); }
The text was updated successfully, but these errors were encountered:
Would you like to submit a PR?
Sorry, something went wrong.
No branches or pull requests
Hey, found an issue regarding the null safety on return type of
OrDefault
methods onIDapperSqlBuilderExtensions
as these methods can return null.The
FirstOrDefault
/SingleOrDefault
extension methods return non-nullable types while using the Dapper methods that return a nullable generic type.Dapper:
InterpolatedSql.Dapper:
IDapperSqlBuilderExtensions.cs
Adding a nullable return type would solve the issue
The text was updated successfully, but these errors were encountered: