Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Count #68

Merged
merged 4 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>2.1.6</Version>
<Version>2.1.7</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>TakasakiStudio.Lina.AspNet</PackageId>
<Authors>TakasakiStudio</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>2.1.6</Version>
<Version>2.1.7</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>TakasakiStudio.Lina.AutoDependencyInjection</PackageId>
<Authors>TakasakiStudio</Authors>
Expand Down
4 changes: 2 additions & 2 deletions TakasakiStudio.Lina.Common/TakasakiStudio.Lina.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>2.1.6</Version>
<Version>2.1.7</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>TakasakiStudio.Lina.Common</PackageId>
<Title>TakasakiStudio.Lina.Common</Title>
Expand All @@ -20,7 +20,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentValidation" Version="11.9.2" />
<PackageReference Include="FluentValidation" Version="11.10.0" />
</ItemGroup>

<ItemGroup>
Expand Down
13 changes: 13 additions & 0 deletions TakasakiStudio.Lina.Database/Interfaces/IBaseRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ public interface IBaseRepository<TEntity, in TPkType>
/// <param name="expression">Expression filter</param>
/// <returns>Returns if entity exists</returns>
ValueTask<bool> Exists(Expression<Func<TEntity, bool>> expression);

/// <summary>
/// Base function for get number of registers by filter
/// </summary>
/// <param name="expression">Expression filter</param>
/// <returns>Return number of register by filter</returns>
ValueTask<int> Count(Expression<Func<TEntity, bool>> expression);

/// <summary>
/// Base function for get number of registers
/// </summary>
/// <returns>Return number of register</returns>
ValueTask<int> Count();

/// <summary>
/// Base function for add entity in database
Expand Down
19 changes: 19 additions & 0 deletions TakasakiStudio.Lina.Database/Repositories/BaseRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,25 @@ public async ValueTask<bool> Exists(Expression<Func<TEntity, bool>> expression)
{
return await DbContext.Set<TEntity>().AnyAsync(expression);
}

/// <summary>
/// Get number of registers by filter
/// </summary>
/// <param name="expression">Expression filter</param>
/// <returns>Return number of register by filter</returns>
public async ValueTask<int> Count(Expression<Func<TEntity, bool>> expression)
{
return await DbContext.Set<TEntity>().CountAsync(expression);
}

/// <summary>
/// Get number of registers
/// </summary>
/// <returns>Return number of register</returns>
public async ValueTask<int> Count()
{
return await DbContext.Set<TEntity>().CountAsync();
}

/// <summary>
/// Add entity in database
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>2.1.6</Version>
<Version>2.1.7</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>TakasakiStudio.Lina.Database</PackageId>
<Title>TakasakiStudio.Lina.Database</Title>
Expand Down
6 changes: 3 additions & 3 deletions TakasakiStudio.Lina.Test/TakasakiStudio.Lina.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.5.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.5.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.0" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
2 changes: 1 addition & 1 deletion TakasakiStudio.Lina.Utils/TakasakiStudio.Lina.Utils.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>2.1.6</Version>
<Version>2.1.7</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>TakasakiStudio.Lina.Utils</PackageId>
<Title>TakasakiStudio.Lina.Utils</Title>
Expand Down
2 changes: 1 addition & 1 deletion TakasakiStudio.Lina/TakasakiStudio.Lina.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>2.1.6</Version>
<Version>2.1.7</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>TakasakiStudio.Lina</PackageId>
<Title>TakasakiStudio.Lina</Title>
Expand Down