it looks like there was an ExecuteScalar in Dapper...
http://code.google.com/p/dapper-dot-net/issues/attachmentText?id=22&aid=220000000&name=ExecuteScalar.cs&token=9e2fd8899022f507b140ffb883c60e34
Was ExecuteScalar renamed or removed?
Can this now be achieved with .Query or .Query<T>?
ExecuteScalar<T> Returns an instance of the type specified by the T type parameter. ExecuteScalarAsync. Returns a dynamic type asynchronously.
The DynamicParameters type provides an Add method, enabling you to pass explicit parameters, specifying the datatype, direction and size: var parameters = new DynamicParameters(); var customerId = "ALFKI"; parameters. Add("@CustomerId", customerId, DbType.
Dapper has no DB specific implementation details, it works across all . NET ADO providers including SQLite, SQL CE, Firebird, Oracle, MySQL, PostgreSQL and SQL Server. Dapper was created by team at Stack Overflow. To utilize Dapper, we add the package reference to the project with the dotnet tool.
ExecuteScalar was just added in 1.28: https://www.nuget.org/packages/Dapper
I was able to call ExecuteScalar< T > with version 1.42.0
public Boolean BeforeToday(DateTime dateInQuestion)
{
try
{
using (var conn = new SqlConnection(ConnectionString))
{
String sql = @"SELECT CONVERT(bit, CASE WHEN getdate() > @dateParameter THEN 1 ELSE 0 END) AS BeforeToday";
var result = conn.ExecuteScalar<Boolean>(sql, new { dateParameter = dateInQuestion });
return result;
}
}
catch (Exception)
{
return dateInQuestion < DateTime.Now;
}
}
In version 1.50.4 I was able to call
connection.QuerySingle<int>(query,params)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With