• 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);
        ....
    }
  • 相关阅读:
    PCRE
    [转]如何解决严重的拖延症
    linux系统编程:setjmp和longjmp函数用法
    AWK中几个变量
    关于fork函数
    go mod
    golang+read_file+call_shell+goroutine
    vim for galang
    Linux install go
    为Git branch 打Tag
  • 原文地址:https://www.cnblogs.com/kzwrcom/p/8303608.html
Copyright © 2020-2023  润新知