zoukankan      html  css  js  c++  java
  • 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);
        ....
    }
  • 相关阅读:
    谈敏捷的好文章
    梁信军说的话
    如何做需求管理
    支持向量机通俗解释
    如何写数据报告
    数据分析注意点
    傅盛谈管理的本质
    I Hate It HDU
    敌兵布阵 HDU
    P3372 【模板】线段树 1 (区间查询)
  • 原文地址:https://www.cnblogs.com/kzwrcom/p/8303608.html
Copyright © 2011-2022 走看看