public ProjectionEvaluator(ParameterAggregator parameterAggregator, System.Type inputType, Func<Expression, bool> predicate)
 {
     _parameterAggregator = parameterAggregator;
     _inputParameter = Expression.Parameter(inputType, "input");
     _predicate = predicate;
     _hqlTreeBuilder = new HqlTreeBuilder();
     _stack = new HqlNodeStack(_hqlTreeBuilder);
 }
		public static CommandData GenerateHqlQuery(QueryModel queryModel, ParameterAggregator aggregator)
		{
			// Rewrite aggregate group by statements
			new AggregatingGroupByRewriter().VisitQueryModel(queryModel);

			// Swap out non-aggregating group bys
			new NonAggregatingGroupByRewriter().VisitQueryModel(queryModel);

            // Merge aggregating result operators (distinct, count, sum etc) into the select clause
		    new MergeAggregatingResultsRewriter().VisitQueryModel(queryModel);

			var visitor = new QueryModelVisitor(aggregator);
			visitor.VisitQueryModel(queryModel);
			return visitor.GetHqlCommand();
		}
		private QueryModelVisitor(ParameterAggregator parameterAggregator)
		{
			_hqlTreeBuilder = new HqlTreeBuilder();
			_parameterAggregator = parameterAggregator;
		}