EAV under entity 4 and ddd

Some tables in my database are designed using the EAV concept. Then I use the objects that are generated automatically and represent the "static" tables (and not the "EAV" tables) of the ORM Entity Framework as DDD objects.

  • How can I use "EAV" objects in an object model (not in a relational one, like in a database) using the Entity Framework?

For instance,
in the database I have static Report and EAV tables that help me store ReportProperty for the report.
In the domain model, I want to have a report like this:

Report { ICollection<ReportProperty> ReportProperties{get;set;} } 

I can use the Report object generated by the Entity Framework and implement some logic in the getter in the partial section to extract data from my EAV tables to populate the Collection ReportProperies. He then asks the following question.

  1. What should I do if I decide to use NHibernate instead of the Entity Framework because I cannot use my partial partition, which I already understand using the Entity Framework?

If I use DDD objects that I can use for Entity Framework or NHibernate, this is unlikely to be for me, because I will need call matching procedures in each procedure of my DAO.

+4
source share
1 answer

EAV is the concept of the data access layer, and DDD is the concept of the business logic level. ORM, like Entity Framework or NHibernate, forces us to mix these two levels, but in complex projects with complex logic (that is, where DDD is required) this should never happen. So separate your Dahl and Bl. Use the manually created classes for the DDD objects and use the automatically generated (or first at the beginning) classes for the Entity Framework and providing a mapping layer between them. Then EAV will be just a detail of the implementation of your Dal. In addition, your Bll and DDD classes should not change if you switch to NHibernate. Only your display layer will be. And by the way, use Dependency Inversion. Make your Dal Bll dependent on you, not the other way around. If you make the mapping layer physically separate from the Entity Framework parts, use the assembly-level mediator template (this means that your mapping layer depends on your Bll and your Dal, and not vice versa).

+1
source

Source: https://habr.com/ru/post/1332868/


All Articles