Question

I have NHibernate models that I'm torn if I should map as collections. To illustrate the problem in simple terms, a Person is always referenced on all tables, is it wise to map all the tables that references the Person as Person's another property, i.e. collections. Is this too bloated?

To prevent XY problem with my question:

What I wanted to achieve is to do a LEFT JOIN from Person to another table, a simple JOIN would not suffice, as I needed to report all Person even they don't have a collection, hence this calls for Linq's DefaultIfEmpty, however NHibernate doesn't support DefaultIfEmpty yet. However, I don't want to use QueryOver as this query API looks byzantine, a 30 line SQL/Linq will become 100 lines with QueryOver. Is it good to map all models that references the Person model as Person's collections to so I can still use Linq? And will just use FetchMany on the child tables of the Person?

However, the colleague don't want to overly map all the models, as he think that the models will become bloated, especially for master tables like Person. He opines too that the domain model should act only as facade for data store. Is that a practical approach for domain modeling?

I just use the Person model to illustrate the problem in simplest terms, there are many business models that I think should be mapped as collection to another model. This also precludes the need to use QueryOver API when doing LEFT JOINs, and consequently we can still use Linq and FetchMany

Was it helpful?

Solution

There is no such thing as a bloated model.

References and collections that your code doesn't use are left alone by NH.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top