What is dependency injection. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is dependency injection.

I'm working on a project that uses C#, XAML, and entity framework (database first approach). Will it be good if I use dependency injection on it or not? I want to inject the Database Context on every form that I have but that seems impossible using XAML.

9th Feb 2024, 11:55 AM
Jomari Tenorio
Jomari Tenorio - avatar
1 Answer
0
public class MyViewModel { private readonly MyDbContext _dbContext; public MyViewModel(MyDbContext dbContext) { _dbContext = dbContext; } }
4th Mar 2024, 12:23 PM
Անի Մուրադյան
Անի Մուրադյան - avatar