Added new projects: NDB.Core.Abstractions + NDB.Data.EntityFramework
parent
7aed7268b8
commit
9dae387602
17
NDB.sln
17
NDB.sln
|
@ -60,6 +60,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NDB.Test.Api", "NDB.Test.Ap
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NDB.Infrastructure.DatabaseMigration", "infrastructure\NDB.Infrastructure.DatabaseMigration\NDB.Infrastructure.DatabaseMigration.csproj", "{74C7BE02-DD5C-49C2-8E88-E3AEA729E2AB}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NDB.Infrastructure.DatabaseMigration", "infrastructure\NDB.Infrastructure.DatabaseMigration\NDB.Infrastructure.DatabaseMigration.csproj", "{74C7BE02-DD5C-49C2-8E88-E3AEA729E2AB}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NDB.Data.EntityFramework", "src\data\NDB.Data.EntityFramework\NDB.Data.EntityFramework.csproj", "{15650720-30F3-4FF3-8D4A-9B21BBA5E273}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "core", "core", "{FD5D4A32-E6A7-4808-B43E-A906B1B81956}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NDB.Core.Abstractions", "src\core\NDB.Core.Abstractions\NDB.Core.Abstractions.csproj", "{A15F25DD-2B42-49AB-BBA8-E9D9B78630A1}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -110,6 +116,14 @@ Global
|
||||||
{74C7BE02-DD5C-49C2-8E88-E3AEA729E2AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{74C7BE02-DD5C-49C2-8E88-E3AEA729E2AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{74C7BE02-DD5C-49C2-8E88-E3AEA729E2AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{74C7BE02-DD5C-49C2-8E88-E3AEA729E2AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{74C7BE02-DD5C-49C2-8E88-E3AEA729E2AB}.Release|Any CPU.Build.0 = Release|Any CPU
|
{74C7BE02-DD5C-49C2-8E88-E3AEA729E2AB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{15650720-30F3-4FF3-8D4A-9B21BBA5E273}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{15650720-30F3-4FF3-8D4A-9B21BBA5E273}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{15650720-30F3-4FF3-8D4A-9B21BBA5E273}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{15650720-30F3-4FF3-8D4A-9B21BBA5E273}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{A15F25DD-2B42-49AB-BBA8-E9D9B78630A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{A15F25DD-2B42-49AB-BBA8-E9D9B78630A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{A15F25DD-2B42-49AB-BBA8-E9D9B78630A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{A15F25DD-2B42-49AB-BBA8-E9D9B78630A1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -138,6 +152,9 @@ Global
|
||||||
{CCEE458E-02A8-42FD-8F5F-A35481A23303} = {E0202271-4E92-4DB8-900D-B5FD745B9278}
|
{CCEE458E-02A8-42FD-8F5F-A35481A23303} = {E0202271-4E92-4DB8-900D-B5FD745B9278}
|
||||||
{F717BE3D-F5F4-4D99-B96D-D0A23E8BED01} = {CCEE458E-02A8-42FD-8F5F-A35481A23303}
|
{F717BE3D-F5F4-4D99-B96D-D0A23E8BED01} = {CCEE458E-02A8-42FD-8F5F-A35481A23303}
|
||||||
{74C7BE02-DD5C-49C2-8E88-E3AEA729E2AB} = {1C1D634E-06CC-4707-9564-E31A76F27D9E}
|
{74C7BE02-DD5C-49C2-8E88-E3AEA729E2AB} = {1C1D634E-06CC-4707-9564-E31A76F27D9E}
|
||||||
|
{15650720-30F3-4FF3-8D4A-9B21BBA5E273} = {7D49E538-B89A-4BC2-AD5A-5A658F4B74E4}
|
||||||
|
{FD5D4A32-E6A7-4808-B43E-A906B1B81956} = {E0202271-4E92-4DB8-900D-B5FD745B9278}
|
||||||
|
{A15F25DD-2B42-49AB-BBA8-E9D9B78630A1} = {FD5D4A32-E6A7-4808-B43E-A906B1B81956}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {87541BAB-3FAC-4ADB-A7FB-8228DA87843D}
|
SolutionGuid = {87541BAB-3FAC-4ADB-A7FB-8228DA87843D}
|
||||||
|
|
|
@ -22,4 +22,7 @@ dotnet nuget push NDB.Security.Authentication.Identity.1.0.7.nupkg -k ****KEY***
|
||||||
dotnet nuget push NDB.Extensions.Caching.1.0.1.nupkg -k ****KEY**** -s https://toodle.ddns.net/public-nuget-server/nuget
|
dotnet nuget push NDB.Extensions.Caching.1.0.1.nupkg -k ****KEY**** -s https://toodle.ddns.net/public-nuget-server/nuget
|
||||||
|
|
||||||
dotnet nuget push NDB.Infrastructure.DatabaseMigration.1.1.3.nupkg -k ****KEY**** -s https://toodle.ddns.net/public-nuget-server/nuget
|
dotnet nuget push NDB.Infrastructure.DatabaseMigration.1.1.3.nupkg -k ****KEY**** -s https://toodle.ddns.net/public-nuget-server/nuget
|
||||||
|
|
||||||
|
dotnet nuget push NDB.Data.EntityFramework.1.0.1.nupkg -k ****KEY**** -s https://toodle.ddns.net/public-nuget-server/nuget
|
||||||
|
dotnet nuget push NDB.Core.Abstractions.1.0.0.nupkg -k ****KEY**** -s https://toodle.ddns.net/public-nuget-server/nuget
|
||||||
#######################################################################################################################################################
|
#######################################################################################################################################################
|
|
@ -0,0 +1,14 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
<Description>NDB core abstractions</Description>
|
||||||
|
<PackageReleaseNotes>NDB core abstractions</PackageReleaseNotes>
|
||||||
|
<PackageProjectUrl>https://toodle.ddns.net/gitea/bricks/ndb</PackageProjectUrl>
|
||||||
|
<RepositoryUrl>https://toodle.ddns.net/gitea/bricks/ndb</RepositoryUrl>
|
||||||
|
<RepositoryType>Git</RepositoryType>
|
||||||
|
<PackageTags>NDB Core</PackageTags>
|
||||||
|
<Version>1.0.0</Version>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,14 @@
|
||||||
|
namespace NDB.Core.Abstractions.Paging
|
||||||
|
{
|
||||||
|
public class PageRequest
|
||||||
|
{
|
||||||
|
public int Page { get; }
|
||||||
|
public int PageSize { get; }
|
||||||
|
|
||||||
|
public PageRequest(int page, int pageSize)
|
||||||
|
{
|
||||||
|
Page = page <= 0 ? 1 : page;
|
||||||
|
PageSize = pageSize <= 0 ? 10 : pageSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace NDB.Core.Abstractions.Paging
|
||||||
|
{
|
||||||
|
public class PagedResult<TEntity>
|
||||||
|
{
|
||||||
|
public int Page { get; }
|
||||||
|
public int PageSize { get; }
|
||||||
|
public int TotalCount { get; }
|
||||||
|
public int TotalPages { get; }
|
||||||
|
public IEnumerable<TEntity> Values { get; }
|
||||||
|
|
||||||
|
public PagedResult(int page, int pageSize, int totalCount, int totalPages, IEnumerable<TEntity> values)
|
||||||
|
{
|
||||||
|
Page = page;
|
||||||
|
PageSize = pageSize;
|
||||||
|
TotalCount = totalCount;
|
||||||
|
TotalPages = totalPages;
|
||||||
|
Values = values;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PagedResult<TDestination> Map<TDestination>(Func<TEntity, TDestination> mapperFunc)
|
||||||
|
{
|
||||||
|
return new PagedResult<TDestination>(Page, PageSize, TotalCount, TotalPages, Values.Select(mapperFunc));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
|
namespace NDB.Data.EntityFramework.Extensions
|
||||||
|
{
|
||||||
|
public static class LinqExtensions
|
||||||
|
{
|
||||||
|
public static IOrderedQueryable<TSource> OrderBy<TSource, TKey>(this IQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, bool descending)
|
||||||
|
{
|
||||||
|
return descending ? source.OrderByDescending(keySelector) : source.OrderBy(keySelector);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using NDB.Core.Abstractions.Paging;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace NDB.Data.EntityFramework.Extensions
|
||||||
|
{
|
||||||
|
public static class PagedResultExtensions
|
||||||
|
{
|
||||||
|
public static async Task<PagedResult<TEntity>> ToPagedResult<TEntity>(this IQueryable<TEntity> query, PageRequest pageRequest, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
var page = pageRequest.Page;
|
||||||
|
var pageSize = pageRequest.PageSize;
|
||||||
|
|
||||||
|
var totalCount = await query.CountAsync(cancellationToken);
|
||||||
|
var values = await query.Skip(pageSize * (page - 1)).Take(pageSize).ToArrayAsync(cancellationToken);
|
||||||
|
|
||||||
|
var totalPages = totalCount / pageSize + (totalCount % pageSize > 0 ? 1 : 0);
|
||||||
|
|
||||||
|
var result = new PagedResult<TEntity>(page, pageSize, totalCount, totalPages, values);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
<Description>EntityFramework extensions</Description>
|
||||||
|
<PackageReleaseNotes>EntityFramework extensions</PackageReleaseNotes>
|
||||||
|
<PackageProjectUrl>https://toodle.ddns.net/gitea/bricks/ndb</PackageProjectUrl>
|
||||||
|
<RepositoryUrl>https://toodle.ddns.net/gitea/bricks/ndb</RepositoryUrl>
|
||||||
|
<RepositoryType>Git</RepositoryType>
|
||||||
|
<PackageTags>NDB EntityFramework</PackageTags>
|
||||||
|
<Version>1.0.1</Version>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.7" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\core\NDB.Core.Abstractions\NDB.Core.Abstractions.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
Loading…
Reference in New Issue