|
@@ -168,7 +168,7 @@ public class MeterValueDbService
|
|
|
|
|
|
t1 = watch.ElapsedMilliseconds;
|
|
|
using SqlConnection sqlConnection = await sqlConnectionFactory.CreateAsync();
|
|
|
- using var trans = await sqlConnection.BeginTransactionAsync();
|
|
|
+ //using var trans = await sqlConnection.BeginTransactionAsync();
|
|
|
|
|
|
t2 = watch.ElapsedMilliseconds;
|
|
|
|
|
@@ -178,12 +178,14 @@ public class MeterValueDbService
|
|
|
var tableName = group.Key;
|
|
|
foreach(var param in group)
|
|
|
{
|
|
|
- await InsertWithNoCheckDapper(tableName, param, sqlConnection, trans);
|
|
|
+ await InsertWithNoCheckDapper(tableName, param, sqlConnection
|
|
|
+ //, trans
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
t3 = watch.ElapsedMilliseconds;
|
|
|
- await trans.CommitAsync();
|
|
|
+ //await trans.CommitAsync();
|
|
|
|
|
|
watch.Stop();
|
|
|
t4 = watch.ElapsedMilliseconds;
|
|
@@ -200,7 +202,8 @@ public class MeterValueDbService
|
|
|
VALUES (@ConnectorId, @Value, @CreatedOn, @ContextId, @FormatId, @MeasurandId, @PhaseId, @LocationId, @UnitId, @ChargeBoxId, @TransactionId);
|
|
|
""";
|
|
|
|
|
|
- SqlConnection connection = conn ?? await sqlConnectionFactory.CreateAsync();
|
|
|
+ bool isLocalConnection = conn is null;
|
|
|
+ SqlConnection connection = isLocalConnection ? await sqlConnectionFactory.CreateAsync() : conn;
|
|
|
|
|
|
var parameters = new DynamicParameters();
|
|
|
parameters.Add("ConnectorId", data.connectorId, DbType.Int16);
|
|
@@ -216,6 +219,11 @@ public class MeterValueDbService
|
|
|
parameters.Add("TransactionId", data.transactionId, DbType.Int32);
|
|
|
|
|
|
await connection.ExecuteAsync(command, parameters, trans);
|
|
|
+
|
|
|
+ if (isLocalConnection)
|
|
|
+ {
|
|
|
+ connection.Dispose();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private async Task BulkInsertWithBulkCopy(IEnumerable<InsertMeterValueParam> parms)
|