Last active
July 30, 2020 10:04
-
-
Save PradeepLoganathan/e87a8b14ec396f19120cd4c7e83acd4f to your computer and use it in GitHub Desktop.
inject repositories and DbContext
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using BookStore.Domain.BooksAggregate; | |
| using Microsoft.EntityFrameworkCore; | |
| using Microsoft.Extensions.DependencyInjection; | |
| namespace BookStore.Repository | |
| { | |
| public static class DependencyInjection | |
| { | |
| public static IServiceCollection AddRepository(this IServiceCollection services) | |
| { | |
| services.AddTransient<IBooksRepository, BooksRepository>(); | |
| services.AddTransient<ICatalogueRepository, CatalogueRepository>(); | |
| services.AddTransient<IUnitOfWork, UnitOfWork>(); | |
| services.AddDbContext<BookStoreDbContext>(opt => opt | |
| .UseSqlServer("Server=localhost,1433; Database=BooksDB;User Id=sa; Password=password_01;")); | |
| return services; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment