From 1d3534ab46a74e9a612f99a2d48c73b79fe869cf Mon Sep 17 00:00:00 2001 From: pavelbannov Date: Fri, 30 Jun 2023 14:57:19 +0300 Subject: [PATCH] fixed query --- common/ASC.Core.Common/Data/DbUserService.cs | 21 ++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/common/ASC.Core.Common/Data/DbUserService.cs b/common/ASC.Core.Common/Data/DbUserService.cs index b712b88abf..6d0df6c314 100644 --- a/common/ASC.Core.Common/Data/DbUserService.cs +++ b/common/ASC.Core.Common/Data/DbUserService.cs @@ -321,7 +321,7 @@ public class EFUserService : IUserService await using var userDbContext = _dbContextFactory.CreateDbContext(); var ids = await CollectGroupChildsAsync(userDbContext, tenant, id); var stringIds = ids.Select(r => r.ToString()).ToList(); - + userDbContext.Acl.RemoveRange(await Queries.AclsByIdsAsync(userDbContext, tenant, ids).ToListAsync()); userDbContext.Subscriptions.RemoveRange(await Queries.SubscriptionsByIdsAsync(userDbContext, tenant, stringIds).ToListAsync()); userDbContext.SubscriptionMethods.RemoveRange(await Queries.DbSubscriptionMethodsByIdsAsync(userDbContext, tenant, stringIds).ToListAsync()); @@ -871,21 +871,21 @@ static file class Queries EF.CompileAsyncQuery( (UserDbContext ctx, int tenantId, string userName, Guid id) => ctx.Users - .Where(r => r.TenantId != Tenant.DefaultTenant && r.TenantId == tenantId) + .Where(r => tenantId == Tenant.DefaultTenant || r.TenantId == tenantId) .Any(r => r.UserName == userName && r.Id != id && !r.Removed)); public static readonly Func> AnyUsersByEmailAsync = EF.CompileAsyncQuery( (UserDbContext ctx, int tenantId, string email, Guid id) => ctx.Users - .Where(r => r.TenantId != Tenant.DefaultTenant && r.TenantId == tenantId) + .Where(r => tenantId == Tenant.DefaultTenant || r.TenantId == tenantId) .Any(r => r.Email == email && r.Id != id && !r.Removed)); public static readonly Func> FirstOrDefaultUserAsync = EF.CompileAsyncQuery( (UserDbContext ctx, int tenantId, Guid id) => ctx.Users - .Where(r => r.TenantId != Tenant.DefaultTenant && r.TenantId == tenantId) + .Where(r => tenantId == Tenant.DefaultTenant || r.TenantId == tenantId) .FirstOrDefault(a => a.Id == id)); public static readonly Func> UserPhotoAsync = @@ -899,11 +899,12 @@ static file class Queries EF.CompileAsyncQuery( (UserDbContext ctx, int tenantId) => (from usersDav in ctx.UsersDav - join users in ctx.Users on new { tenant = usersDav.TenantId, userId = usersDav.UserId } equals new - { - tenant = users.TenantId, userId = users.Id - } - where usersDav.TenantId == tenantId - select users.Email) + join users in ctx.Users on new { tenant = usersDav.TenantId, userId = usersDav.UserId } equals new + { + tenant = users.TenantId, + userId = users.Id + } + where usersDav.TenantId == tenantId + select users.Email) .Distinct()); } \ No newline at end of file