From 7dd714edb2e5ce3ed23256a9eb3ee7798486e3c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Mon, 28 Nov 2022 13:35:38 +0300 Subject: [PATCH] Add source code link --- .../2022-11-28-EF-Core-Entity-Dependency-Injection/POST.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/en/Community-Articles/2022-11-28-EF-Core-Entity-Dependency-Injection/POST.md b/docs/en/Community-Articles/2022-11-28-EF-Core-Entity-Dependency-Injection/POST.md index 2759bfed16..8ed92d43c2 100644 --- a/docs/en/Community-Articles/2022-11-28-EF-Core-Entity-Dependency-Injection/POST.md +++ b/docs/en/Community-Articles/2022-11-28-EF-Core-Entity-Dependency-Injection/POST.md @@ -2,6 +2,8 @@ [Dependency injection](https://docs.abp.io/en/abp/latest/Dependency-Injection) is a widely-used pattern of obtaining references to other services from our classes. It is a built-in feature when you develop ASP.NET Core applications. In this article, I will explain why we may need to have references to other services in an entity class and how we can implement Entity Framework Core's new `IMaterializationInterceptor` interface to provide these services to the entities using the standard dependency injection system. +> You can find the source code of the example application [here](https://github.com/abpframework/abp-samples/tree/master/EfCoreEntityDependencyInjectionDemo). + ## The Problem While developing applications based on [Domain-Driven Design](https://docs.abp.io/en/abp/latest/Domain-Driven-Design) (DDD) patterns, we typically write our business code inside [application services](https://docs.abp.io/en/abp/latest/Application-Services), [domain services](https://docs.abp.io/en/abp/latest/Domain-Services) and [entities](https://docs.abp.io/en/abp/latest/Entities). Since the application and domain service instances are created by the dependency injection system, they can inject services into their constructors. @@ -367,6 +369,11 @@ In this article, I tried to investigate all aspects of injecting services into e Injecting services into entities seems a certain way of forcing some business rules in your entities. However, because of the current technical limitations, design issues and usage difficulties, I don't suggest to depend on services in your entities. Instead, create domain services when you need to implement a business rule that depends on external services and entities. +## The Source Code + +* You can find the full source code of the example application [here](https://github.com/abpframework/abp-samples/tree/master/EfCoreEntityDependencyInjectionDemo). +* You can see [this pull request](https://github.com/abpframework/abp-samples/pull/207/files) for the changes I've done after creating the application. + ## See Also * [What's new in EF Core 7.0](https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-7.0/whatsnew)