Closed ltond closed 3 years ago
Hello @ltond ,
What's the DbConnection
full name? Are you using something like MiniProfiler or your use your own custom connection?
Best Regards,
Jon
Hi @JonathanMagnan,
DbConnection.ToString():
Dapper.Logging.Hooks.WrappedConnection`1[[Dapper.Logging.Empty, Dapper.Logging, Version=0.4.3.0, Culture=neutral, PublicKeyToken=9516ed96e39666d6]]
It happens when running locally, the connection string is of the form Server=localhost;Database=...;User Id=...;Password=...;
No MiniProfiler or custom connection here.
From above it looks like we are using https://github.com/hryz/Dapper.Logging for the AddDbConnectionFactory extension method and the wrapper round the DbConnection. This was added for logging SQL queries to output - would we be better off switching to MiniProfiler?
Hello @ltond ,
We normally "bypass" that kind of profiler. Since we need to make some reflection (we don't have any provider dependencies), trying to support all this kind of profiler would be way too hard.
So if you wish to use our library, use the real connection. For example, a SqlConnection
.
You can also get easily the underlying connection using reflection of this WrappedConnection
: https://github.com/hryz/Dapper.Logging/blob/ad531477ac8ecd5c1d9d3fa6de868746aad86eff/src/Dapper.Logging/Hooks/WrappedConnection.cs#L11
something like this (code has not been tested):
public static DbConnection GetInnerConnection<T>(this WrappedConnection<T> wrappedConnection)
{
var connectionField = wrappedConnection.GetField("_connection", BindingFlags.NonPublic | BindingFlags.Instance);
var connection = connectionField.GetValue(wrappedConnection);
return connection;
}
Best Regards,
Jon
We are seeing this error
The Provider could not be resolved. You must explicitly set the Provider.'
when trying to call
DbConnection.BulkInsert
using the Dapper Plus library.DbConnection here is created via a IDbConnectionFactory - CreateConnection() method. We are bootstrapping the DbConnectionFactory as follows:
Exception stack trace: