What difference does it make to have 1 or more objects of Country?
anyway its either you save these calculation in the DB or perform them on-the-fly.
I don't know if you can dynamically instruct NHibernate to return a property or not, but there are definitely 2 things you can do:
1) Map the Cities collection with lazy load so it's not fetched automatically.
2) Create a second diluted Country type and map only the relevant fields, without the cities collection.
Hope this helps,
Shaul
meyer wrote:
Thanks for the quick response.
Few remarks:
1. updating these calculated fields in update/delete is not relevant and I don't need this functionality.
2. Maybe the most important issue that I didn't mention is that I my result most of the time will be of type List<Country>.
For 1 country, I can get a mapped object of type Country, and then run the HQL query that you wrote below but my problem is that I need to get a List of dozens of countries and each one should have these calculated properties.
As I mentioned above, I am looking for a generic solution where I will be able to ask for list of countries and indicate which calculated properties I want to get in the returned collection (if any)...
Thanks!