Dependencyinjection.cs 1.1 KB

12345678910111213141516171819202122232425262728
  1. using Microsoft.Extensions.DependencyInjection;
  2. using AipGateway.API.Domain.IRepositories.IGenericRepositories;
  3. using AipGateway.API.Domain.Models;
  4. using Microsoft.Extensions.Configuration;
  5. using AipGateway.API.Infrastructure.DataAccess;
  6. using AipGateway.API.Infrastructure.Persistence;
  7. using Microsoft.EntityFrameworkCore;
  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. );
  21. services.AddScoped<IUnitOfWork, UnitOfWorkRepository>();
  22. //services.AddSingleton<UnitOfWorkRepository>();
  23. return services;
  24. }
  25. }
  26. }