コード例 #1
0
 public void TestApplyWithFewerElementsThanMaxResults()
 {
     MaxResultsExitOperation exitOp = new MaxResultsExitOperation(8);
     List<Object> list = new List<object> {1, 2, null, 3, 4, 5};
     IList objects = exitOp.Apply(list);
     Assert.AreEqual(5, objects.Count);
     AssertNoNullElements(objects);
     Assert.AreEqual(new List<object> {1, 2, 3, 4, 5}, objects);
 }
コード例 #2
0
        public IList Apply(IList result)
        {
            if (firstResult.HasValue)
            {
                result = new FirstResultExitOperation(firstResult.Value).Apply(result);
            }
            if (maxResults.HasValue)
            {
                result = new MaxResultsExitOperation(maxResults.Value).Apply(result);
            }

            return result;
        }
コード例 #3
0
        public IList Apply(IList result)
        {
            /**
             * Herein lies the glory
             *
             * hibernate has done as much as it can, we're going to have to deal with
             * the rest in memory.
             *
             * The heirarchy of operations is this so far:
             * Distinct
             * Order
             * FirstResult
             * MaxResult
             * RowCount
             * Average
             * Min/Max/Sum
             */

            // ordering of the following operations *really* matters!
            if (distinct != null)
            {
                result = new DistinctExitOperation(distinct).Apply(result);
            }
            foreach (Order order in orders)
            {
                result = new OrderExitOperation(order).Apply(result);
            }
            if (firstResult != null)
            {
                result = new FirstResultExitOperation((int) firstResult).Apply(result);
            }
            if (maxResults != null)
            {
                result = new MaxResultsExitOperation((int) maxResults).Apply(result);
            }
            ProjectionExitOperationFactory factory = ProjectionExitOperationFactory.GetFactory();

            if (rowCountProjection != null)
            {
                result = factory.GetProjectionExitOperation(rowCountProjection, sessionFactoryImplementor).Apply(result);
            }
            if (avgProjection != null)
            {
                result = new AvgResultsExitOperation().Apply(result);
            }
            // min, max, sum
            if (aggregateProjection != null)
            {
                result = factory.GetProjectionExitOperation(aggregateProjection, sessionFactoryImplementor).Apply(result);
            }

            return result;
        }