- ABP Framework version: 8.0.2
- UI Type: Angular
- Database System: MongoDB
- Tiered (for MVC) or Auth Server Separated (for Angular): yes
- Exception message and full stack trace:
- Steps to reproduce the issue:
I am writing to ask about searched implemented in default modules like saas, administration. When using Mongodb they are all case sensitive even for Contains comparison . Which is pretty annoying. When you searching for tenants or user you want searches to be case insensitive as you searching for some partial key and ignore case should be implemented. Have you guys have any work currently pending regrading that. Or if not can you point me to right direction how to implement is globally. This is source code I am referring to which does case sensitive search
public virtual async Task<List<Tenant>> GetListAsync(
string sorting = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,
string filter = null,
bool includeDetails = false,
Guid? editionId = null,
DateTime? expirationDateMin = null,
DateTime? expirationDateMax = null,
TenantActivationState? tenantActivationState = null,
CancellationToken cancellationToken = default)
{
return await (await GetMongoQueryableAsync(cancellationToken))
.WhereIf<Tenant, IMongoQueryable<Tenant>>(
!filter.IsNullOrWhiteSpace(),
u =>
u.Name.Contains(filter)
)
.WhereIf(editionId.HasValue, tenant => tenant.EditionId == editionId.Value)
.WhereIf(expirationDateMin.HasValue, tenant => tenant.EditionEndDateUtc >= expirationDateMin.Value)
.WhereIf(expirationDateMax.HasValue, tenant => tenant.EditionEndDateUtc <= expirationDateMax.Value)
.WhereIf(tenantActivationState.HasValue, tenant => tenant.ActivationState == tenantActivationState.Value)
.OrderBy(sorting.IsNullOrWhiteSpace() ? nameof(Tenant.Name) : sorting)
.As<IMongoQueryable<Tenant>>()
.PageBy<Tenant, IMongoQueryable<Tenant>>(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
}
5 Answer(s)
-
0
Hello ,
Please check this https://stackoverflow.com/questions/4458950/mongodb-and-c-case-insensitive-search try to add
ToLowerat both side (frontend and backend).Thank you.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
I am talking about existing framework code. It seems like I have to override all framework repository for this fix. Tenants, Users administration modules. Do you have any planned work for this ?
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi,
I will check it.https://github.com/abpframework/abp/issues/19030
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hello , Please check this https://stackoverflow.com/questions/4458950/mongodb-and-c-case-insensitive-search try to add ToLower at both side (frontend and backend). Thank you.This solution does not work with Mongodb Linq.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi,
It works for me:
protected virtual IQueryable<Book> ApplyFilter( IQueryable<Book> query, string? filterText = null, string? name = null, string? title = null) { return query .WhereIf(!string.IsNullOrWhiteSpace(filterText), e => e.Name!.ToLower().Contains(filterText!.ToLower()) || e.Title!.ToLower().Contains(filterText!.ToLower())) .WhereIf(!string.IsNullOrWhiteSpace(name), e => e.Name!.ToLower().Contains(name!.ToLower())) .WhereIf(!string.IsNullOrWhiteSpace(title), e => e.Title!.ToLower().Contains(title!.ToLower())); }Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
