0
rasoulshams created
- 9.1
- Mvc
- .Net core
I know settings can be accessed from application services, domain services and controllers using base classes or by injecting ISettingManager but how can settings be accessed from within entities and aggregate roots inside the core project? Some of my entities require the settings datas but I can't access them from entities.
I'd appreciate if someone can help.
1 Answer(s)
-
0
Hi rasoulshams, This is not a good implementation, Normally, domain objects will not inject external dependencies. You can process this part of the logic in DomainService and pass it to the domain objects.
If you really want to do this, you can use a static instance of IocManager in the entity.
public class ProductEntity : Entity<int>, ITransientDependency { public string Name { get; set; } public string Description { get; set; } public void Get() { var settingMgr = IocManager.Instance.Resolve<ISettingManager>(); } }