Skip to content

twobitranch.io

Creating abstractions to avoid possible future problems in ASP.NET Core

ASP.NET Core makes dependency injection so easy that creating abstractions can sometimes become automatic. Create an interface.Create an implementation.Register both with the DI container.Inject the interface into the controller or service. For example:builder.Services.AddScoped<IOrderService, OrderService>(); Then:public class OrdersController : ControllerBase {… Read More »Creating abstractions to avoid possible future problems in ASP.NET Core