Mike Cole
Mike Cole

Reputation: 14733

Selecting count of child object collection in NHibernate

I have a Customer object that has a child Orders collection. I have this relationship set up in the mapping file with Orders being lazy-loaded. Is it possible to lazy-load only the count of Orders instead of the entire collection? If so, how?

Thanks!

Upvotes: 0

Views: 537

Answers (1)

Joachim Kerschbaumer
Joachim Kerschbaumer

Reputation: 9881

maybe you could try using a formula (see nhibenate mapping reference) to execute sql code and get the value directly into a property. this could use the count() function of your rdbms which avoids loading the entities at all.

Upvotes: 2

Related Questions