Active record pattern is famous for Ruby on Rails. The method of using typed dataset for a wide range of ASP. NET streams is actually active record pattern.
Because typed dataset has many drawbacks and is not a pojo entity, I was denied at the beginning, but unfortunately, I also denied active record pattern.
In fact, this mode is quite successful on the premise of "database-driven web system. Because entity life cycle in such a system can be very short.
- A life cycle is generated from the database and ends on the binding interface.
- Another life cycle starts from collecting user input and ends with saving it to the database.
In the database-driven web system, adding active record pattern with the lightweight pojo entity is very suitable.
There is nothing wrong with the concept of domain driven design, but do not forget to further refine the application premise, such as what the model should look like on the web. The entity of the system model may not be directly used in the web system. The OOP principle advocated by gof is "favor interface over base class ". The core meaning is to focus only on the part that must be known in the system. It is also necessary to design a lightweight entity for different application scenarios.
This requires lightweight Orm. Load the database data into entity, and save the data in Entity back to the database. Lightweight is only this function. Do not attempt to manage entity life cycle, do not pursue container level transaction, or create an application server.
In fact, MS is aware of this and will include Entity Data Model (EDM) in the next generation of ADO. net, see the ADO. NET Entity Framework overview. Canceling the release of object space several times does not mean that it is not important, but that it is so important that it must be placed in a more appropriate location, such as the. NET core location, ADO. net. This makes the fans of Typed Dataset speechless.