The transaction associated with this command is not the connection's active transaction
- 前端
- Easter79
- 0
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);
....
}
免责申明:本站发布的内容(图片、视频和文字)以转载和分享为主,文章观点不代表本站立场,如涉及侵权请联系站长邮箱:xbc-online@qq.com进行反馈,一经查实,将立刻删除涉嫌侵权内容。