RepoDB icon indicating copy to clipboard operation
RepoDB copied to clipboard

Bug: DbRepository's Truncate operations do not handle transactions

Open zetomatoz opened this issue 3 years ago • 1 comments

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
}

zetomatoz avatar Mar 29 '22 20:03 zetomatoz

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.

mikependon avatar Mar 30 '22 08:03 mikependon