From 52df8f65835adcc3a54b72397db9ad2b0ffb50c6 Mon Sep 17 00:00:00 2001 From: Ike Kottlowski Date: Thu, 26 Jun 2025 18:01:28 -0400 Subject: [PATCH] fix: sync ef query with view by joining also on UserId and making the expiration time check inclusive. --- .../Auth/Repositories/AuthRequestRepository.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Infrastructure.EntityFramework/Auth/Repositories/AuthRequestRepository.cs b/src/Infrastructure.EntityFramework/Auth/Repositories/AuthRequestRepository.cs index 34f95da9c5..23cdb60dcd 100644 --- a/src/Infrastructure.EntityFramework/Auth/Repositories/AuthRequestRepository.cs +++ b/src/Infrastructure.EntityFramework/Auth/Repositories/AuthRequestRepository.cs @@ -72,11 +72,12 @@ public class AuthRequestRepository : Repository DateTime.UtcNow + where authRequest.CreationDate.AddMinutes(expirationMinutes) >= DateTime.UtcNow group authRequest by authRequest.RequestDeviceIdentifier into groupedAuthRequests select (from r in groupedAuthRequests - join d in dbContext.Devices on r.RequestDeviceIdentifier equals d.Identifier into deviceJoin + join d in dbContext.Devices on new { r.RequestDeviceIdentifier, r.UserId } + equals new { RequestDeviceIdentifier = d.Identifier, d.UserId } into deviceJoin from dj in deviceJoin.DefaultIfEmpty() // This creates a left join allowing null for devices orderby r.CreationDate descending select new PendingAuthRequestDetails(r, dj.Id)).First()