Introduced a robust Infrastructure layer for the ECMJobRunner system: - Added `AGENTS.md` with detailed project documentation. - Implemented generic repository and unit-of-work patterns. - Added `CfgProfileRepository`, `ProfileSqlJobRepository`, and `ProfileHistoryRepository`. - Integrated AutoMapper for DTO-to-entity mapping. - Added multi-framework support for .NET Framework 4.8 (EF6) and .NET 8.0 (EF Core) using conditional compilation. - Updated `ECMJobRunner.Infrastructure.csproj` with metadata fixes and dependencies. - Introduced dependency injection extension for .NET 8.0. - Enhanced project structure and database context with entity mappings.
42 lines
1.5 KiB
C#
42 lines
1.5 KiB
C#
#if NET48
|
|
using System.Data.Entity;
|
|
#else
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
#endif
|
|
using ECMJobRunner.Domain.Interfaces;
|
|
using ECMJobRunner.Infrastructure.Data;
|
|
using ECMJobRunner.Infrastructure.Repositories;
|
|
|
|
namespace ECMJobRunner.Infrastructure
|
|
{
|
|
#if !NET48
|
|
/// <summary>
|
|
/// Dependency injection extension methods for Infrastructure layer
|
|
/// </summary>
|
|
public static class DependencyExtension
|
|
{
|
|
/// <summary>
|
|
/// Add Infrastructure services to dependency injection container
|
|
/// </summary>
|
|
/// <param name="services">Service collection</param>
|
|
/// <param name="connectionString">Database connection string</param>
|
|
/// <returns>Service collection for chaining</returns>
|
|
public static IServiceCollection AddInfrastructure(this IServiceCollection services, string connectionString)
|
|
{
|
|
// Register DbContext
|
|
services.AddDbContext<JobRunnerDbContext>(options =>
|
|
options.UseSqlServer(connectionString));
|
|
|
|
// Register repositories
|
|
services.AddScoped(typeof(IRepository<>), typeof(Repository<>));
|
|
services.AddScoped<ICfgProfileRepository, CfgProfileRepository>();
|
|
services.AddScoped<IProfileSqlJobRepository, ProfileSqlJobRepository>();
|
|
services.AddScoped<IProfileHistoryRepository, ProfileHistoryRepository>();
|
|
|
|
return services;
|
|
}
|
|
}
|
|
#endif
|
|
}
|