Search code examples
nhibernatequeryovernhibernate-projections

Can you project multiple aggregates from a single QueryOver


I can create a single aggregate projection on a collection of entities

example Return the number of shops that are active

But is there a way to project the number of a bunch of different summations in the same query over?

example

number of shops that are active?

Number of shops with active products?

Number of inactive shops?

Then ultimately project these into new properties using the select method.

If you can't do it all within one queryover is there a way to create individual sub queries and join them together to project them (as new properties) into one object?


Solution

  • I don't think you can do it with a single QueryOver, because QueryOver is just a wrapper for Criteria.

    You can use multi criteria for this. Create several QueryOvers and use the property UnderlyingCriteria to add it to the MultiCriteria.