RepoDB
RepoDB copied to clipboard
Bug: DbRepository's Truncate operations do not handle transactions
The DbRepository class' Truncate methods do not handle the transaction argument correctly. A connection instance gets created even if transaction is not null, which leads to runtime issues.
public int Truncate<TEntity>(IDbTransaction transaction = null) where TEntity : class
{
// Create a connection
var connection = CreateConnection();
// Code removed for brevity
}
We should get the following implementation as it is done with the other DbRepository's operations:
public int Truncate<TEntity>(IDbTransaction transaction = null) where TEntity : class
{
// Create a connection
var connection = (transaction?.Connection ?? CreateConnection())
// Code removed for brevity
}
Thanks for reporting. It is a simple fix though. We are glad if you can also make a PR of this, otherwise we will do the fix and it will be a part of the release.