I am trying to understand how the Dependency Injection service registry works. I have a generic repository that does database operations for any table such as GetAll(), GetById() ... and another service that will commit to the database. such as Save(); Commit();
I have read AddTransient, AddScoped and AddSingleton Services Differences?
My question is what would be the best option to register the Generic Repository service and Db service and why?
services.AddScoped (typeof (IRepository<>), typeof (Repository<>));
services.AddTransient (typeof (IRepository<>), typeof (Repository<>));
services.AddSingleton (typeof (IRepository<>), typeof (Repository<>));