From c079cdcda2c55dcea5161b30510b9b8f64aa0830 Mon Sep 17 00:00:00 2001 From: Enis Necipoglu Date: Mon, 18 Dec 2023 10:34:33 +0300 Subject: [PATCH] Use `IsNullOrEmpty` instead null-check in repository --- .../EntityFrameworkCore/EfCoreAuditLogRepository.cs | 12 ++++++------ .../AuditLogging/MongoDB/MongoAuditLogRepository.cs | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/EfCoreAuditLogRepository.cs b/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/EfCoreAuditLogRepository.cs index add342e075..86ed8461e4 100644 --- a/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/EfCoreAuditLogRepository.cs +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/EfCoreAuditLogRepository.cs @@ -126,13 +126,13 @@ public class EfCoreAuditLogRepository : EfCoreRepository auditLog.ExecutionTime <= endTime) .WhereIf(hasException.HasValue && hasException.Value, auditLog => auditLog.Exceptions != null && auditLog.Exceptions != "") .WhereIf(hasException.HasValue && !hasException.Value, auditLog => auditLog.Exceptions == null || auditLog.Exceptions == "") - .WhereIf(httpMethod != null, auditLog => auditLog.HttpMethod == httpMethod) - .WhereIf(url != null, auditLog => auditLog.Url != null && auditLog.Url.Contains(url)) + .WhereIf(!httpMethod.IsNullOrEmpty(), auditLog => auditLog.HttpMethod == httpMethod) + .WhereIf(!url.IsNullOrEmpty(), auditLog => auditLog.Url != null && auditLog.Url.Contains(url)) .WhereIf(userId != null, auditLog => auditLog.UserId == userId) - .WhereIf(userName != null, auditLog => auditLog.UserName == userName) - .WhereIf(applicationName != null, auditLog => auditLog.ApplicationName == applicationName) - .WhereIf(clientIpAddress != null, auditLog => auditLog.ClientIpAddress != null && auditLog.ClientIpAddress == clientIpAddress) - .WhereIf(correlationId != null, auditLog => auditLog.CorrelationId == correlationId) + .WhereIf(!userName.IsNullOrEmpty(), auditLog => auditLog.UserName == userName) + .WhereIf(!applicationName.IsNullOrEmpty(), auditLog => auditLog.ApplicationName == applicationName) + .WhereIf(!clientIpAddress.IsNullOrEmpty(), auditLog => auditLog.ClientIpAddress != null && auditLog.ClientIpAddress == clientIpAddress) + .WhereIf(!correlationId.IsNullOrEmpty(), auditLog => auditLog.CorrelationId == correlationId) .WhereIf(httpStatusCode != null && httpStatusCode > 0, auditLog => auditLog.HttpStatusCode == nHttpStatusCode) .WhereIf(maxExecutionDuration != null && maxExecutionDuration.Value > 0, auditLog => auditLog.ExecutionDuration <= maxExecutionDuration) .WhereIf(minExecutionDuration != null && minExecutionDuration.Value > 0, auditLog => auditLog.ExecutionDuration >= minExecutionDuration); diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs b/modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs index 1dc8b50778..2ffdd20fd6 100644 --- a/modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs @@ -128,13 +128,13 @@ public class MongoAuditLogRepository : MongoDbRepository auditLog.ExecutionTime <= endTime) .WhereIf(hasException.HasValue && hasException.Value, auditLog => auditLog.Exceptions != null && auditLog.Exceptions != "") .WhereIf(hasException.HasValue && !hasException.Value, auditLog => auditLog.Exceptions == null || auditLog.Exceptions == "") - .WhereIf(httpMethod != null, auditLog => auditLog.HttpMethod == httpMethod) - .WhereIf(url != null, auditLog => auditLog.Url != null && auditLog.Url.Contains(url)) + .WhereIf(!httpMethod.IsNullOrEmpty(), auditLog => auditLog.HttpMethod == httpMethod) + .WhereIf(!url.IsNullOrEmpty(), auditLog => auditLog.Url != null && auditLog.Url.Contains(url)) .WhereIf(userId != null, auditLog => auditLog.UserId == userId) - .WhereIf(userName != null, auditLog => auditLog.UserName == userName) - .WhereIf(applicationName != null, auditLog => auditLog.ApplicationName == applicationName) - .WhereIf(clientIpAddress != null, auditLog => auditLog.ClientIpAddress == clientIpAddress) - .WhereIf(correlationId != null, auditLog => auditLog.CorrelationId == correlationId) + .WhereIf(!userName.IsNullOrEmpty(), auditLog => auditLog.UserName == userName) + .WhereIf(!applicationName.IsNullOrEmpty(), auditLog => auditLog.ApplicationName == applicationName) + .WhereIf(!clientIpAddress.IsNullOrEmpty(), auditLog => auditLog.ClientIpAddress == clientIpAddress) + .WhereIf(!correlationId.IsNullOrEmpty(), auditLog => auditLog.CorrelationId == correlationId) .WhereIf(httpStatusCode != null && httpStatusCode > 0, auditLog => auditLog.HttpStatusCode == (int?)httpStatusCode) .WhereIf(maxDuration != null && maxDuration > 0, auditLog => auditLog.ExecutionDuration <= maxDuration) .WhereIf(minDuration != null && minDuration > 0, auditLog => auditLog.ExecutionDuration >= minDuration);