From the course: Expert Domain-Driven Design (DDD) Implementation in .NET

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Persisting data in the ManagementApplicationService class

Persisting data in the ManagementApplicationService class - .NET Tutorial

From the course: Expert Domain-Driven Design (DDD) Implementation in .NET

Persisting data in the ManagementApplicationService class

- [Instructor] Up to now, we have the management application service class, where we're injecting the IBreedService as part of its primary structure. Additionally, we registered the concrete implementation of IBreedService into dependence injection container, and we're using the IBreedService object to create a fully validated breed ID object. Now what about persistence? As I've mentioned before, some people choose to use a repository object, but instead we'll inject the DB context right here. So management Db context, and let's name it dbContext. And let's wrap every parameter, just like this. And here, let's use dbContext and then Pets AddAsync newPet and let's wait for this. And finally SaveChangesAsync. Okay, now we need to register management application service in the dependence injection container as well. So let's open up program. And here, let's type builder services, and then add scope, Management ApplicationService. And since we don't have an interface, we can register the…

Contents