Is it possible to use the use of O / RM, for example NHibernate or Entity Framework, and abstract it so that it can be replaced if there is a situation that O / RM cannot handle.
It seems tempting to create a service with short service methods, within which the session is created, the session is used to get / unload entities and then used to save all dirty objects.
I would consider a repository template so that a service operation requests a repository for entities and an O / RM session is embedded in the repository. But what do you do with storing related objects, and also that the T entity flush method changes immediately. It seems simple and generally unsatisfactory.
What I am referring to right now is one O / RM shell class that provides an interface with generic methods like "StartSession", "EndSession", "AbandonSession", "GetById (object id)", etc.
At the very least, this can lead to OR / M being faked during testing, which is another big problem.
I think I'm saying that I don’t want to closely interconnect the business logic and the O / RM data access code, because switching to another O / RM can replace most of this code.
What do people do in the real world?
Iant8 source
share