#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
///
/// Dependency injection extension methods for Infrastructure layer
///
public static class DependencyExtension
{
///
/// Add Infrastructure services to dependency injection container
///
/// Service collection
/// Database connection string
/// Service collection for chaining
public static IServiceCollection AddInfrastructure(this IServiceCollection services, string connectionString)
{
// Register DbContext
services.AddDbContext(options =>
options.UseSqlServer(connectionString));
// Register repositories
services.AddScoped(typeof(IRepository<>), typeof(Repository<>));
services.AddScoped();
services.AddScoped();
services.AddScoped();
return services;
}
}
#endif
}