From c5d041bb32382a26ab546357247e9da5c43bc9d7 Mon Sep 17 00:00:00 2001 From: Gabriel-Paulucci Date: Wed, 2 Oct 2024 19:16:33 -0300 Subject: [PATCH 1/4] Add: count in database --- .../Interfaces/IBaseRepository.cs | 7 +++++++ .../Repositories/BaseRepository.cs | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/TakasakiStudio.Lina.Database/Interfaces/IBaseRepository.cs b/TakasakiStudio.Lina.Database/Interfaces/IBaseRepository.cs index cf42256..d2b5766 100644 --- a/TakasakiStudio.Lina.Database/Interfaces/IBaseRepository.cs +++ b/TakasakiStudio.Lina.Database/Interfaces/IBaseRepository.cs @@ -39,6 +39,13 @@ public interface IBaseRepository /// Expression filter /// Returns if entity exists ValueTask Exists(Expression> expression); + + /// + /// Base function for get number of registers by filter + /// + /// Expression filter + /// Return number of register by filter + ValueTask CountAll(Expression> expression); /// /// Base function for add entity in database diff --git a/TakasakiStudio.Lina.Database/Repositories/BaseRepository.cs b/TakasakiStudio.Lina.Database/Repositories/BaseRepository.cs index c754c26..077494d 100644 --- a/TakasakiStudio.Lina.Database/Repositories/BaseRepository.cs +++ b/TakasakiStudio.Lina.Database/Repositories/BaseRepository.cs @@ -60,6 +60,16 @@ public async ValueTask Exists(Expression> expression) { return await DbContext.Set().AnyAsync(expression); } + + /// + /// Get number of registers by filter + /// + /// Expression filter + /// Return number of register by filter + public async ValueTask CountAll(Expression> expression) + { + return await DbContext.Set().CountAsync(expression); + } /// /// Add entity in database From 055a903206ff6993646620def61ca251312884f0 Mon Sep 17 00:00:00 2001 From: Gabriel-Paulucci Date: Wed, 2 Oct 2024 19:17:20 -0300 Subject: [PATCH 2/4] Update: dependencies --- .../TakasakiStudio.Lina.Common.csproj | 2 +- TakasakiStudio.Lina.Test/TakasakiStudio.Lina.Test.csproj | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/TakasakiStudio.Lina.Common/TakasakiStudio.Lina.Common.csproj b/TakasakiStudio.Lina.Common/TakasakiStudio.Lina.Common.csproj index 5cc849d..d19339b 100644 --- a/TakasakiStudio.Lina.Common/TakasakiStudio.Lina.Common.csproj +++ b/TakasakiStudio.Lina.Common/TakasakiStudio.Lina.Common.csproj @@ -20,7 +20,7 @@ - + diff --git a/TakasakiStudio.Lina.Test/TakasakiStudio.Lina.Test.csproj b/TakasakiStudio.Lina.Test/TakasakiStudio.Lina.Test.csproj index 527ad8d..1075862 100644 --- a/TakasakiStudio.Lina.Test/TakasakiStudio.Lina.Test.csproj +++ b/TakasakiStudio.Lina.Test/TakasakiStudio.Lina.Test.csproj @@ -10,9 +10,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive From 87cea4d38d806c5438284e27d91aa62ccd5db43e Mon Sep 17 00:00:00 2001 From: Gabriel-Paulucci Date: Wed, 2 Oct 2024 19:18:18 -0300 Subject: [PATCH 3/4] Update: lina version --- TakasakiStudio.Lina.AspNet/TakasakiStudio.Lina.AspNet.csproj | 2 +- .../TakasakiStudio.Lina.AutoDependencyInjection.csproj | 2 +- TakasakiStudio.Lina.Common/TakasakiStudio.Lina.Common.csproj | 2 +- .../TakasakiStudio.Lina.Database.csproj | 2 +- TakasakiStudio.Lina.Utils/TakasakiStudio.Lina.Utils.csproj | 2 +- TakasakiStudio.Lina/TakasakiStudio.Lina.csproj | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/TakasakiStudio.Lina.AspNet/TakasakiStudio.Lina.AspNet.csproj b/TakasakiStudio.Lina.AspNet/TakasakiStudio.Lina.AspNet.csproj index 0c065ce..d832756 100644 --- a/TakasakiStudio.Lina.AspNet/TakasakiStudio.Lina.AspNet.csproj +++ b/TakasakiStudio.Lina.AspNet/TakasakiStudio.Lina.AspNet.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 2.1.6 + 2.1.7 true TakasakiStudio.Lina.AspNet TakasakiStudio diff --git a/TakasakiStudio.Lina.AutoDependencyInjection/TakasakiStudio.Lina.AutoDependencyInjection.csproj b/TakasakiStudio.Lina.AutoDependencyInjection/TakasakiStudio.Lina.AutoDependencyInjection.csproj index 02f5a77..cef3113 100644 --- a/TakasakiStudio.Lina.AutoDependencyInjection/TakasakiStudio.Lina.AutoDependencyInjection.csproj +++ b/TakasakiStudio.Lina.AutoDependencyInjection/TakasakiStudio.Lina.AutoDependencyInjection.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 2.1.6 + 2.1.7 true TakasakiStudio.Lina.AutoDependencyInjection TakasakiStudio diff --git a/TakasakiStudio.Lina.Common/TakasakiStudio.Lina.Common.csproj b/TakasakiStudio.Lina.Common/TakasakiStudio.Lina.Common.csproj index d19339b..9f572c8 100644 --- a/TakasakiStudio.Lina.Common/TakasakiStudio.Lina.Common.csproj +++ b/TakasakiStudio.Lina.Common/TakasakiStudio.Lina.Common.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 2.1.6 + 2.1.7 true TakasakiStudio.Lina.Common TakasakiStudio.Lina.Common diff --git a/TakasakiStudio.Lina.Database/TakasakiStudio.Lina.Database.csproj b/TakasakiStudio.Lina.Database/TakasakiStudio.Lina.Database.csproj index d891679..d580bb2 100644 --- a/TakasakiStudio.Lina.Database/TakasakiStudio.Lina.Database.csproj +++ b/TakasakiStudio.Lina.Database/TakasakiStudio.Lina.Database.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 2.1.6 + 2.1.7 true TakasakiStudio.Lina.Database TakasakiStudio.Lina.Database diff --git a/TakasakiStudio.Lina.Utils/TakasakiStudio.Lina.Utils.csproj b/TakasakiStudio.Lina.Utils/TakasakiStudio.Lina.Utils.csproj index 9f8e4ec..d29f361 100644 --- a/TakasakiStudio.Lina.Utils/TakasakiStudio.Lina.Utils.csproj +++ b/TakasakiStudio.Lina.Utils/TakasakiStudio.Lina.Utils.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 2.1.6 + 2.1.7 true TakasakiStudio.Lina.Utils TakasakiStudio.Lina.Utils diff --git a/TakasakiStudio.Lina/TakasakiStudio.Lina.csproj b/TakasakiStudio.Lina/TakasakiStudio.Lina.csproj index d3dd9ef..36d8439 100644 --- a/TakasakiStudio.Lina/TakasakiStudio.Lina.csproj +++ b/TakasakiStudio.Lina/TakasakiStudio.Lina.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 2.1.6 + 2.1.7 true TakasakiStudio.Lina TakasakiStudio.Lina From 10279c97e54cbd75115e054f5afd01edde13adb4 Mon Sep 17 00:00:00 2001 From: Gabriel-Paulucci Date: Wed, 2 Oct 2024 19:23:35 -0300 Subject: [PATCH 4/4] Add: overload with not expression --- .../Interfaces/IBaseRepository.cs | 8 +++++++- .../Repositories/BaseRepository.cs | 11 ++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/TakasakiStudio.Lina.Database/Interfaces/IBaseRepository.cs b/TakasakiStudio.Lina.Database/Interfaces/IBaseRepository.cs index d2b5766..74b350e 100644 --- a/TakasakiStudio.Lina.Database/Interfaces/IBaseRepository.cs +++ b/TakasakiStudio.Lina.Database/Interfaces/IBaseRepository.cs @@ -45,7 +45,13 @@ public interface IBaseRepository /// /// Expression filter /// Return number of register by filter - ValueTask CountAll(Expression> expression); + ValueTask Count(Expression> expression); + + /// + /// Base function for get number of registers + /// + /// Return number of register + ValueTask Count(); /// /// Base function for add entity in database diff --git a/TakasakiStudio.Lina.Database/Repositories/BaseRepository.cs b/TakasakiStudio.Lina.Database/Repositories/BaseRepository.cs index 077494d..841e412 100644 --- a/TakasakiStudio.Lina.Database/Repositories/BaseRepository.cs +++ b/TakasakiStudio.Lina.Database/Repositories/BaseRepository.cs @@ -66,10 +66,19 @@ public async ValueTask Exists(Expression> expression) /// /// Expression filter /// Return number of register by filter - public async ValueTask CountAll(Expression> expression) + public async ValueTask Count(Expression> expression) { return await DbContext.Set().CountAsync(expression); } + + /// + /// Get number of registers + /// + /// Return number of register + public async ValueTask Count() + { + return await DbContext.Set().CountAsync(); + } /// /// Add entity in database