From 90b48366258ac2e7304c911b6cd6aabd4eece01c Mon Sep 17 00:00:00 2001 From: Andre Goncalves Date: Wed, 29 Jul 2026 10:32:58 -0700 Subject: [PATCH] AB#33919 - fix tenant map reconciler uow issue --- .../TenantMappings/ApplicantTenantMapReconciler.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/applications/Unity.GrantManager/src/Unity.GrantManager.Application/ApplicantProfile/TenantMappings/ApplicantTenantMapReconciler.cs b/applications/Unity.GrantManager/src/Unity.GrantManager.Application/ApplicantProfile/TenantMappings/ApplicantTenantMapReconciler.cs index 0c43076a10..3786039698 100644 --- a/applications/Unity.GrantManager/src/Unity.GrantManager.Application/ApplicantProfile/TenantMappings/ApplicantTenantMapReconciler.cs +++ b/applications/Unity.GrantManager/src/Unity.GrantManager.Application/ApplicantProfile/TenantMappings/ApplicantTenantMapReconciler.cs @@ -10,6 +10,7 @@ using Volo.Abp.Domain.Repositories; using Volo.Abp.MultiTenancy; using Volo.Abp.TenantManagement; +using Volo.Abp.Uow; namespace Unity.GrantManager.ApplicantProfile; @@ -22,6 +23,7 @@ public class ApplicantTenantMapReconciler( ITenantRepository tenantRepository, IRepository applicantTenantMapRepository, IRepository applicationFormSubmissionRepository, + IUnitOfWorkManager unitOfWorkManager, ILogger logger) : IApplicantTenantMapReconciler, ITransientDependency { @@ -41,6 +43,7 @@ public class ApplicantTenantMapReconciler( logger.LogDebug("Collecting submissions from tenant: {TenantName}", tenant.Name); using (currentTenant.Change(tenant.Id)) + using (var unitOfWork = unitOfWorkManager.Begin(requiresNew: true)) { var submissionQueryable = await applicationFormSubmissionRepository.GetQueryableAsync(); var distinctOidcSubs = await submissionQueryable @@ -49,6 +52,8 @@ public class ApplicantTenantMapReconciler( .Distinct() .ToListAsync(); + await unitOfWork.CompleteAsync(); + foreach (var oidcSub in distinctOidcSubs) { var subUsername = SubjectNormalizer.Normalize(oidcSub); @@ -78,6 +83,7 @@ public class ApplicantTenantMapReconciler( int totalMappingsUpdated = 0; using (currentTenant.Change(null)) + using (var unitOfWork = unitOfWorkManager.Begin(requiresNew: true)) { var allSubUsernames = desiredMappings.Select(m => m.SubUsername).Distinct().ToList(); @@ -113,6 +119,8 @@ public class ApplicantTenantMapReconciler( subUsername, tenantName); } } + + await unitOfWork.CompleteAsync(); } logger.LogInformation("ApplicantTenantMap reconciliation completed. Created: {Created}, Updated: {Updated}",