EDIT 1: When trying to call the extension method explicitly:
Dapper.SqlMapper.QueryAsync<dynamic>(cnx, "SELECT TOP 10 * FROM dbo.Company;");
I have a much more explicit error message:
The type 'SqlMapper' exists in both 'Dapper.StrongName, Version=1.50.2.0, Culture=neutral, PublicKeyToken=e3e8412083d25dd3' and 'Dapper, Version=1.50.5.0, Culture=neutral, PublicKeyToken=null'
Can I do something about it ?
Dapper.StrongName is a dependency of MiniProfiler (.Net standard 1.5)
I'm trying to use MiniProfiler alongside Dapper to see SQL commands send to the backend.
I have the following code to produce an instrumented connection on demand:
private static DbConnection GetCnx(bool instrumented = false)
{
var cnx = new SqlConnection("Data Source=foo;Initial Catalog=bar;Integrated Security=SSPI;");
// Enabling statistics for logging purposes
if (instrumented)
return new ProfiledDbConnection(cnx, MiniProfiler.Current);
else
return cnx;
}
The following consuming code won't compile anymore:
using (DbConnection cnx = GetCnx())
{
await cnx.OpenAsync();
return await cnx.QueryAsync<dynamic>("SELECT TOP 10 * FROM dbo.Company;");
}
The call is ambiguous between the following methods or properties: 'Dapper.SqlMapper.QueryAsync(System.Data.IDbConnection, string, object, System.Data.IDbTransaction, int?, System.Data.CommandType?)' and 'Dapper.SqlMapper.QueryAsync(System.Data.IDbConnection, string, object, System.Data.IDbTransaction, int?, System.Data.CommandType?)'
The ambiguous methods are identical, unless I need a new pair of glass.
What am I missing here ?