From 1d453ca9cbcf05070816f3a19595e8850cf2884c Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 24 Jan 2024 09:35:24 -0500 Subject: [PATCH] fix broken grant delete --- .../Auth/Repositories/GrantRepository.cs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/Infrastructure.EntityFramework/Auth/Repositories/GrantRepository.cs b/src/Infrastructure.EntityFramework/Auth/Repositories/GrantRepository.cs index f22384afbc5d..09fd46835b42 100644 --- a/src/Infrastructure.EntityFramework/Auth/Repositories/GrantRepository.cs +++ b/src/Infrastructure.EntityFramework/Auth/Repositories/GrantRepository.cs @@ -19,11 +19,7 @@ public async Task DeleteByKeyAsync(string key) using (var scope = ServiceScopeFactory.CreateScope()) { var dbContext = GetDatabaseContext(scope); - var query = from g in dbContext.Grants - where g.Key == key - select g; - dbContext.Remove(query); - await dbContext.SaveChangesAsync(); + await dbContext.Grants.Where(g => g.Key == key).ExecuteDeleteAsync(); } } @@ -32,14 +28,11 @@ public async Task DeleteManyAsync(string subjectId, string sessionId, string cli using (var scope = ServiceScopeFactory.CreateScope()) { var dbContext = GetDatabaseContext(scope); - var query = from g in dbContext.Grants - where g.SubjectId == subjectId && - g.ClientId == clientId && - g.SessionId == sessionId && - g.Type == type - select g; - dbContext.Remove(query); - await dbContext.SaveChangesAsync(); + await dbContext.Grants.Where(g => + g.SubjectId == subjectId && + g.ClientId == clientId && + g.SessionId == sessionId && + g.Type == type).ExecuteDeleteAsync(); } }