12345678910111213141516171819202122232425262728 |
- using Microsoft.Extensions.DependencyInjection;
- using AipGateway.API.Domain.IRepositories.IGenericRepositories;
- using AipGateway.API.Domain.Models;
- using Microsoft.Extensions.Configuration;
- using AipGateway.API.Infrastructure.DataAccess;
- using AipGateway.API.Infrastructure.Persistence;
- using Microsoft.EntityFrameworkCore;
- namespace AipGateway.API.Infrastructure
- {
- public static class Dependencyinjection
- {
- public static IServiceCollection AddInfrastructureLayerServices(this IServiceCollection services, IConfiguration configuration)
- {
- services.Add(new ServiceDescriptor(typeof(ConnectionInfo), new ConnectionInfo(configuration.GetConnectionString("DefaultConnection"))));
- services.AddDbContext<ApplicationDbContext>(options =>
- {
- //options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking)
- //,ServiceLifetime.Transient
- }
- );
- services.AddScoped<IUnitOfWork, UnitOfWorkRepository>();
- //services.AddSingleton<UnitOfWorkRepository>();
- return services;
- }
- }
- }
|