Skip to content
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 @@ -2,29 +2,60 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0;net10.0</TargetFrameworks>
<NoWarn>$(NoWarn);NETSDK1138</NoWarn>
<NuGetAudit>false</NuGetAudit>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<StartupObject>Program</StartupObject>
<NoWarn>$(NoWarn);NETSDK1138</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.15.8" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="[6.0.0,7.0.0)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="[6.0.0,7.0.0)" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="[6.0.0,7.0.0)" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="[6.0.0,7.0.0)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="[7.0.0,8.0.0)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="[7.0.0,8.0.0)" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="[7.0.0,8.0.0)" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="[7.0.0,8.0.0)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="[8.0.0,9.0.0)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="[8.0.0,9.0.0)" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="[8.0.0,9.0.0)" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="[8.0.0,9.0.0)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="[9.0.0,10.0.0)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="[9.0.0,10.0.0)" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="[9.0.0,10.0.0)" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="[9.0.0,10.0.0)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="[10.0.0,11.0.0)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="[10.0.0,11.0.0)" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="[10.0.0,11.0.0)" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="[10.0.0,11.0.0)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\DataArc.EntityFrameworkCore.Demo.Persistence\DataArc.EntityFrameworkCore.Demo.Persistence.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,15 @@ public class RawEmployeeBulkDataBenchmark
private const int MaxRecordCount = 1_000_000;

private IServiceProvider? _serviceProvider;
private IReadOnlyCollection<IDatabaseCreator> _databaseCreators = [];
private IReadOnlyCollection<IDatabaseCreator> _databaseCreators = new List<IDatabaseCreator>();
private ICommandFactory? _commandFactory;

private List<Employee> _allEmployees = [];
private List<Employee> _benchmarkEmployees = [];
private List<Employee> _allEmployees = new List<Employee>();
private List<Employee> _benchmarkEmployees = new List<Employee>();

[Params(62_500, 125_000, 250_000)]
public int RecordCount { get; set; }

//[Params(62_500)]
public int BulkBatchSize => MaxRecordCount;

[GlobalSetup]
Expand All @@ -54,13 +53,13 @@ public void GlobalSetup()
.AddPersistence(configurationManager)
.BuildServiceProvider();

_databaseCreators =
[
_serviceProvider.GetRequiredService<IFinanceDbCreator>(),
_serviceProvider.GetRequiredService<IHrDbCreator>(),
_serviceProvider.GetRequiredService<IItDbCreator>(),
_serviceProvider.GetRequiredService<IOperationsDbCreator>()
];
_databaseCreators = new IDatabaseCreator[]
{
_serviceProvider.GetRequiredService<IGoogleDbCreator>(),
_serviceProvider.GetRequiredService<IMicrosoftDbCreator>(),
_serviceProvider.GetRequiredService<IOpenAiDbCreator>(),
_serviceProvider.GetRequiredService<ISASDbCreator>()
};

_commandFactory = _serviceProvider.GetRequiredService<ICommandFactory>();

Expand Down Expand Up @@ -109,19 +108,19 @@ public async Task<int> ExecuteParallelBulkInsertAsync()
throw new InvalidOperationException($"{nameof(commandBuilder)} was not resolved.");

commandBuilder
.UseDbExecutionContext<IHrDbContext>()
.UseDbExecutionContext<IGoogleDbContext>()
.AddBulk(_benchmarkEmployees, BulkBatchSize);

commandBuilder
.UseDbExecutionContext<IFinanceDbContext>()
.UseDbExecutionContext<IOpenAIDbContext>()
.AddBulk(_benchmarkEmployees, BulkBatchSize);

commandBuilder
.UseDbExecutionContext<IItDbContext>()
.UseDbExecutionContext<IMicrosoftDbContext>()
.AddBulk(_benchmarkEmployees, BulkBatchSize);

commandBuilder
.UseDbExecutionContext<IOperationsDbContext>()
.UseDbExecutionContext<ISolidArcDbContext>()
.AddBulk(_benchmarkEmployees, BulkBatchSize);

var command = await commandBuilder.BuildAsync();
Expand Down
8 changes: 4 additions & 4 deletions DataArc.EntityFrameworkCore.Demo.Benchmark/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"ConnectionStrings": {
"FinanceDb": "Server=.;Database=FinanceDb;Integrated Security=true;TrustServerCertificate=True;",
"HrDb": "Server=.;Database=HrDb;Integrated Security=true;TrustServerCertificate=True;",
"ItDb": "Server=.;Database=ItDb;Integrated Security=true;TrustServerCertificate=True;",
"OperationsDb": "Server=.;Database=OperationsDb;Integrated Security=true;TrustServerCertificate=True;"
"SASDb": "Server=.;Database=SAS_Db;Integrated Security=true;TrustServerCertificate=True;",
"GoogleDb": "Server=.;Database=SAS_GoogleDb;Integrated Security=true;TrustServerCertificate=True;",
"MicrosoftDb": "Server=.;Database=SAS_MicrosoftDb;Integrated Security=true;TrustServerCertificate=True;",
"OpenAiDb": "Server=.;Database=SAS_OpenAiDb;Integrated Security=true;TrustServerCertificate=True;"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace DataArc.EntityFrameworkCore.Demo.Application.Modules.Finance.Features.SalaryAdjustments.Dtos
namespace DataArc.EntityFrameworkCore.Demo.Contracts.Application.Dtos
{
public class EmployeeDto
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using DataArc.EntityFrameworkCore.Demo.Contracts.Application.Dtos;

namespace DataArc.EntityFrameworkCore.Demo.Contracts.Application.Modules.Features.EmployeePerformance.Services
{
public interface IEmployeePerformanceService
{
Task<List<EmployeeDto>> GetConsolidatedTopRatedEmployeesAsync(double rating);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace DataArc.EntityFrameworkCore.Demo.Application.Modules.Finance.Features.SalaryAdjustments.Services
namespace DataArc.EntityFrameworkCore.Demo.Contracts.Application.Modules.Features.SalaryAdjustments.Services
{
public interface ISalaryAdjustmentService
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using DataArc.EntityFrameworkCore.Demo.Contracts.Application.Dtos;

namespace DataArc.EntityFrameworkCore.Demo.Contracts.Application.Modules.Google.Repository
{
public interface IGoogleRepository
{
Task<List<EmployeeDto>> GetTopRatedEmployeesAsync(double rating);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using DataArc.EntityFrameworkCore.Demo.Contracts.Application.Dtos;

namespace DataArc.EntityFrameworkCore.Demo.Contracts.Application.Modules.Microsoft.Repository
{
public interface IMicrosoftRepository
{
Task<List<EmployeeDto>> GetTopRatedEmployeesAsync(double rating);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using DataArc.EntityFrameworkCore.Demo.Contracts.Application.Dtos;

namespace DataArc.EntityFrameworkCore.Demo.Contracts.Application.Modules.OpenAi.Repository
{
public interface IOpenAiRepository
{
Task<List<EmployeeDto>> GetTopRatedEmployeesAsync(double rating);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using DataArc.EntityFrameworkCore.Demo.Contracts.Application.Dtos;

namespace DataArc.EntityFrameworkCore.Demo.Contracts.Application.Modules.SolidArc.Repository
{
public interface ISolidArcRepository
{
Task<List<EmployeeDto>> GetTopRatedEmployeesAsync(double rating);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0;net10.0</TargetFrameworks>
<NoWarn>$(NoWarn);NETSDK1138</NoWarn>
<NuGetAudit>false</NuGetAudit>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0" />
</ItemGroup>

<ItemGroup>
<Compile Remove="Application\Modules\Google\Registration\**" />
<EmbeddedResource Remove="Application\Modules\Google\Registration\**" />
<None Remove="Application\Modules\Google\Registration\**" />
</ItemGroup>

<ItemGroup>
<Folder Include="Application\Modules\Google\Features\" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0;net10.0</TargetFrameworks>
<NoWarn>$(NoWarn);NETSDK1138</NoWarn>
<NuGetAudit>false</NuGetAudit>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\DataArc.EntityFrameworkCore.Demo\DataArc.EntityFrameworkCore.Demo.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0" />
</ItemGroup>

<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
24 changes: 24 additions & 0 deletions DataArc.EntityFrameworkCore.Demo.Host/HostRegistration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

using DataArc.EntityFrameworkCore.Demo.Contracts.Application.Modules.Features.EmployeePerformance.Services;
using DataArc.EntityFrameworkCore.Demo.Contracts.Application.Modules.Features.SalaryAdjustments.Services;
using DataArc.EntityFrameworkCore.Demo.Host.BackgroundServices;
using DataArc.EntityFrameworkCore.Demo.Persistence;

namespace DataArc.EntityFrameworkCore.Demo.Host
{
public static class HostRegistration
{
public static IServiceCollection AddBackgroundServices(this IServiceCollection services, ConfigurationManager configurationManager)
{
// Register Persistence
services.AddPersistence(configurationManager);

// Register Background worker services
services.AddScoped<ISalaryAdjustmentService, SalaryAdjustmentService>();
services.AddScoped<IEmployeePerformanceService, EmployeePerformanceService>();
return services;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

using DataArc.EntityFrameworkCore.Demo.Application.Modules.Finance.Registration;
using DataArc.EntityFrameworkCore.Demo.Application.Workers;
using DataArc.EntityFrameworkCore.Demo.Persistence;
using DataArc.EntityFrameworkCore.Demo.Host.Workers;
using DataArc.EntityFrameworkCore.Demo.Host;
using DataArc.EntityFrameworkCore.Demo;

var host = Host
.CreateDefaultBuilder(args)
Expand All @@ -17,7 +18,8 @@
.Build();

services
.AddFinanceModule(configurationManager)
.AddRepositories(configurationManager)
.AddBackgroundServices(configurationManager)
.AddHostedService<DemoWorkflowWorker>();
})
.Build();
Expand Down
Loading
Loading