I'm making a synchronization application, from Firebird to SQL Server. And I'm using BulkInsert from Dapper Plus.
var fbClient = new FirebirdConnect();
using (var source = fbClient.GetConnection())
{
if (source.State == ConnectionState.Closed)
source.Open();
var sqlClient = new AzureConnect();
using (var target = sqlClient.GetConnection())
{
if (target.State == ConnectionState.Closed)
target.Open();
var lastUpdate = connection.Query<DateTime>($"select coalesce((select max(DateSyncTarget) from {metadados.TargetName}), getdate()-10000) LastUpdate").ToList();
var resultSource = source.Query<MyClass>("select * from MyClass");
target.BulkInsert(resultSource.Where(w => w.Data > lastUpdate[0]));
var resultTargert = target.Query<MyClassSource>("select * from MyClass")
source.BulkInsert(resultTargert.Where(w => w.Data > lastUpdate[0]));//Error here
}
}
Everything happens well when I consult the source to do the insertion in the target.
But when I query on target to insert into source, it is giving the following error:
The Provider could not be resolved. You must explicity set the Provider.
Some idea of what causes the error?
EDITED:
Full stack:
em ..(BulkOperation )
em ..(BulkOperation )
em Z.BulkOperations.BulkOperation.BulkInsert()
em Z.Dapper.Plus.DapperPlusAction.Execute()
em Z.Dapper.Plus.DapperPlusAction..ctor(BaseDapperPlusActionSet action, String key, DapperPlusActionKind kind, Object dataSource)
em Z.Dapper.Plus.DapperPlusActionSet`1.AddAction(String mapperKey, DapperPlusActionKind actionKind, TEntity item)
em Z.Dapper.Plus.DapperPlusActionSet`1.DapperPlusActionSetBuilder(IDbConnection connection, IDbTransaction transaction, String mapperKey, DapperPlusActionKind actionKind, TEntity item, Func`2[] selectors)
em Z.Dapper.Plus.DapperPlusExtensions.BulkInsert[T](IDbConnection connection, String mapperKey, T item, Func`2[] selectors)
em Z.Dapper.Plus.DapperPlusExtensions.BulkInsert[T](IDbConnection connection, T item, Func`2[] selectors)
em Project.Plugins.Utils.Extensions.CommandExtensions.InsertSource[T](IDbConnection connection, IEnumerable result) na D:\Projetos\Project-API-Cloud\project-etl\Project.Plugins.Utils\Extensions\CommandExtensions.cs:linha 52
em Autorizacoes.ERP.LIBSENHA.JobAutorizacoes.Execute(IJobExecutionContext context) na D:\Projetos\Project-API-Cloud\Project-etl\Autorizacoes\JobAutorizacoes.cs:linha 105
Disclaimer: I'm the owner of the project Dapper Plus
Problem
The following error is thrown by Dapper Plus library:
The Provider could not be resolved. You must explicity set the Provider.
Cause
Dapper Plus cannot find the provider from the connection provided.
For example, the connection is probably something like an AzureConnection.
var sqlClient = new AzureConnect();
var target = sqlClient.GetConnection()
var fullName = target.GetType().FullName;
The library currently doesn't know it has to handle this connection in the same way as a SqlConnection.
Solution #1 - SqlConnection Direct
Use directly a SqlConnection instead.
If the current connection is only a wrapper, you may find the SqlConnection under sometimes a property named UnderlyingConnection
or InnerConnection
.
Solution #2 - Report Issue
I recommend you to open an issue here
And provide information about how to use/what to download so we can use the same code as you for AzureConnect
.
We usually fix this kind of issue within a few days.