The transaction associated with this command is not the connection's active transaction


The fix is fairly simple: if you want a Dapper query to participate in a connection, explicitly denote that intent:

private async Task<EResult> ProcessDepotAfterDownload(ManifestJob request, DepotManifest depotManifest)
{
    using (var db = await Database.GetConnectionAsync())
    using (var transaction = await db.BeginTransactionAsync())
    {
        // add `transaction` to method call below
        var result = await ProcessDepotAfterDownload(db, transaction, request, depotManifest);
        await transaction.CommitAsync();
        return result;
    }
}

private async Task<EResult> ProcessDepotAfterDownload(IDbConnection db, IDbTransaction transaction, ManifestJob request, DepotManifest depotManifest)
{
    // pass `transaction` to Dapper's QueryAsync below
    var filesOld = (await db.QueryAsync<DepotFile>("SELECT `ID`, `File`, `Hash`, `Size`, `Flags` FROM `DepotsFiles` WHERE `DepotID` = @DepotID", new { request.DepotID }, transaction: transaction)).ToDictionary(x => x.File, x => x);
    ....
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM