Using custom DTOs

Sometimes, the difference between the domain model and database schema is so great that using NHibernate features to patch the gaps becomes a painful and buggy process. In such a situation, it is best to use custom Data Transfer Objects (DTOs) that are designed to match the database schema. Adding custom DTOs creates an additional layer in your architecture, which comes with its own overheads, and, if not designed with care, may lead to code that is inefficient and difficult to maintain. There is no magic formula to work with DTOs so that your persistence layer becomes more bearable. Fortunately, there is some common wisdom shared by veterans in the field, and a few tricks that I have learned from my experience that should help. ...

Get Learning NHibernate 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.