Dependencyinjection.cs 1.1 KB

123456789101112131415161718192021222324252627
  1. using Microsoft.Extensions.DependencyInjection;
  2. using AipGateway.API.Domain.IRepositories.IGenericRepositories;
  3. using Microsoft.Extensions.Configuration;
  4. using AipGateway.API.Infrastructure.DataAccess;
  5. using AipGateway.API.Infrastructure.Persistence;
  6. using Microsoft.EntityFrameworkCore;
  7. using AipGateway.API.Infrastructure.Configurations;
  8. namespace AipGateway.API.Infrastructure
  9. {
  10. public static class Dependencyinjection
  11. {
  12. public static IServiceCollection AddInfrastructureLayerServices(this IServiceCollection services, IConfiguration configuration)
  13. {
  14. services.Add(new ServiceDescriptor(typeof(ConnectionInfo), new ConnectionInfo(configuration.GetConnectionString("DefaultConnection"))));
  15. services.AddDbContext<ApplicationDbContext>(options =>
  16. {
  17. options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
  18. //ServiceLifetime.Transient;
  19. });
  20. services.AddScoped<IUnitOfWork, UnitOfWorkRepository>();
  21. return services;
  22. }
  23. }
  24. }