code_junkie

What's the best way to get aggregate results from NHibernate?

Nov 11th, 2011
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. Session.CreateCriteria ( typeof ( Order ) )
  2. .Add ( Restrictions.Between ( "DateReceived" , today.AddMonths ( -1 ) , today ) )
  3. .CreateAlias ( "Lines" , "lines" )
  4. .SetProjection (
  5. Projections.ProjectionList ( )
  6. .Add ( Projections.Sum ( "lines.TotalCost" ) )
  7. .Add ( Projections.Avg ( "lines.TotalCost" ) )
  8. .Add ( Projections.GroupProperty ( "Customer" ) )
  9. ) ;
Add Comment
Please, Sign In to add comment