Click here to Skip to main content
15,883,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
From definition:
> Inversion of Control (IoC) means to create instances of dependencies first and latter instance of a class (optionally injecting them through constructor)

is then it a good example of DI and IoC?
Meaning that I create instance in startup (IoC) and then inject it through constructor (DI)? I have hard time understanding IoC, but this seems to be the simpliest example.

also from this article it seems that
is built in example, am I right?

What I have tried:

I have code in

 public void ConfigureServices(IServiceCollection services)
   string connectionString = Configuration.GetConnectionString("DbConnection");
            services.AddDbContext<AppDbContext>(options => options.UseSqlServer(connectionString));
   services.AddScoped<IBooksService, BooksService>();
   services.AddScoped<IBooksRepository, BooksRepository>();

and e.g. controller:

 public BookController(IBooksService booksService, ILogger<BookController> logger)
  _booksService = booksService;
  _logger = logger;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900