Asad
Asad

Reputation: 59

How to add repository to services with AddTransient

This is my project structure:

This is mine Project structure

I want to know how I can add repository to AddTransient

public void ConfigureServices(IServiceCollection services)
{
    services.AddTransient<IDrinkRepository Implementation>();
    services.AddMvc();
}

Upvotes: 1

Views: 915

Answers (1)

Wim Ombelets
Wim Ombelets

Reputation: 5265

I left the (semi-pseudo) code as is.

You'd use it as follows:

services.AddTransient<IDrinkRepository, DrinkRepository>();

where DrinkRepository is a concrete implementation of IDrinkRepository.
Does that answer your question?

Upvotes: 2

Related Questions