From 8958af30c42c9c7d5251e88bc9feab5c38a2e04c Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 28 Sep 2023 11:00:51 +0800 Subject: [PATCH] Search with "contains" instead of exact match while searching users --- .../EfCoreIdentityUserRepository.cs | 10 +++++----- .../Identity/MongoDB/MongoIdentityUserRepository.cs | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs index c52902bfed..6f3eb540f2 100644 --- a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs +++ b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs @@ -188,11 +188,11 @@ public class EfCoreIdentityUserRepository : EfCoreRepository identityUser.Roles.Any(x => x.RoleId == roleId.Value)) .WhereIf(organizationUnitId.HasValue, identityUser => identityUser.OrganizationUnits.Any(x => x.OrganizationUnitId == organizationUnitId.Value)) - .WhereIf(!string.IsNullOrWhiteSpace(userName), x => x.UserName == userName) - .WhereIf(!string.IsNullOrWhiteSpace(phoneNumber), x => x.PhoneNumber == phoneNumber) - .WhereIf(!string.IsNullOrWhiteSpace(emailAddress), x => x.Email == emailAddress) - .WhereIf(!string.IsNullOrWhiteSpace(name), x => x.Name == name) - .WhereIf(!string.IsNullOrWhiteSpace(surname), x => x.Surname == surname) + .WhereIf(!string.IsNullOrWhiteSpace(userName), x => x.UserName.Contains(userName)) + .WhereIf(!string.IsNullOrWhiteSpace(phoneNumber), x => x.PhoneNumber.Contains(phoneNumber)) + .WhereIf(!string.IsNullOrWhiteSpace(emailAddress), x => x.Email.Contains(emailAddress)) + .WhereIf(!string.IsNullOrWhiteSpace(name), x => x.Name.Contains(name)) + .WhereIf(!string.IsNullOrWhiteSpace(surname), x => x.Surname.Contains(surname)) .WhereIf(isLockedOut.HasValue, x => (x.LockoutEnabled && x.LockoutEnd.HasValue && x.LockoutEnd.Value.CompareTo(DateTime.UtcNow) > 0) == isLockedOut.Value) .WhereIf(notActive.HasValue, x => x.IsActive == !notActive.Value) .WhereIf(emailConfirmed.HasValue, x => x.EmailConfirmed == emailConfirmed.Value) diff --git a/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs b/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs index 51960edbba..255e492c05 100644 --- a/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs +++ b/modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs @@ -168,11 +168,11 @@ public class MongoIdentityUserRepository : MongoDbRepository>(roleId.HasValue, identityUser => identityUser.Roles.Any(x => x.RoleId == roleId.Value)) .WhereIf>(organizationUnitId.HasValue, identityUser => identityUser.OrganizationUnits.Any(x => x.OrganizationUnitId == organizationUnitId.Value)) - .WhereIf>(!string.IsNullOrWhiteSpace(userName), x => x.UserName == userName) - .WhereIf>(!string.IsNullOrWhiteSpace(phoneNumber), x => x.PhoneNumber == phoneNumber) - .WhereIf>(!string.IsNullOrWhiteSpace(emailAddress), x => x.Email == emailAddress) - .WhereIf>(!string.IsNullOrWhiteSpace(name), x => x.Name == name) - .WhereIf>(!string.IsNullOrWhiteSpace(surname), x => x.Surname == surname) + .WhereIf>(!string.IsNullOrWhiteSpace(userName), x => x.UserName.Contains(userName)) + .WhereIf>(!string.IsNullOrWhiteSpace(phoneNumber), x => x.PhoneNumber.Contains(phoneNumber)) + .WhereIf>(!string.IsNullOrWhiteSpace(emailAddress), x => x.Email.Contains(emailAddress)) + .WhereIf>(!string.IsNullOrWhiteSpace(name), x => x.Name.Contains(name)) + .WhereIf>(!string.IsNullOrWhiteSpace(surname), x => x.Surname.Contains(surname)) .WhereIf>(isLockedOut.HasValue && isLockedOut.Value, x => x.LockoutEnabled && x.LockoutEnd != null && x.LockoutEnd > DateTimeOffset.UtcNow) .WhereIf>(isLockedOut.HasValue && !isLockedOut.Value, x => !(x.LockoutEnabled && x.LockoutEnd != null && x.LockoutEnd > DateTimeOffset.UtcNow)) .WhereIf>(notActive.HasValue, x => x.IsActive == !notActive.Value)