public void Apply(object container)
			{
				LocalObjectContainer localContainer = (LocalObjectContainer)((IObjectContainer)container
					);
				SodaQueryComparator comparator = new SodaQueryComparator(localContainer, typeof(SodaQueryComparatorBenchmark.Item
					), new SodaQueryComparator.Ordering[] { new SodaQueryComparator.Ordering(SodaQueryComparator.Direction
					.Ascending, new string[] { "name" }), new SodaQueryComparator.Ordering(SodaQueryComparator.Direction
					.Descending, new string[] { "child", "name" }) });
				IQuery query = ((IObjectContainer)container).Query();
				query.Constrain(typeof(SodaQueryComparatorBenchmark.Item));
				IList sortedIds = comparator.Sort(query.Execute().Ext().GetIDs());
				for (IEnumerator idIter = sortedIds.GetEnumerator(); idIter.MoveNext(); )
				{
					int id = ((int)idIter.Current);
					Assert.IsNull(localContainer.GetActivatedObjectFromCache(localContainer.Transaction
						, id));
				}
			}
Exemplo n.º 2
0
		private void AssertQuery(int[] expectedItemIds, SodaQueryComparator.Ordering[] orderings
			)
		{
			long[] ids = NewQuery(typeof(SodaQueryComparatorTestCase.Item)).Execute().Ext().GetIDs
				();
			IList sorted = new SodaQueryComparator(FileSession(), typeof(SodaQueryComparatorTestCase.Item
				), orderings).Sort(ids);
			Iterator4Assert.AreEqual(Iterators.Map(expectedItemIds, oidByItemId), Iterators.Iterator
				(sorted));
		}
		public SodaQueryComparator(LocalObjectContainer container, Type extentType, SodaQueryComparator.Ordering
			[] orderings) : this(container, container.ProduceClassMetadata(container.Reflector
			().ForClass(extentType)), orderings)
		{
		}
			public Ordering(SodaQueryComparator.Direction direction, string[] fieldPath)
			{
				_direction = direction;
				_fieldPath = fieldPath;
			}
		private void ResolveFieldPaths(SodaQueryComparator.Ordering[] orderings)
		{
			for (int fieldPathIndex = 0; fieldPathIndex < orderings.Length; ++fieldPathIndex)
			{
				SodaQueryComparator.Ordering fieldPath = orderings[fieldPathIndex];
				fieldPath._resolvedPath = ResolveFieldPath(fieldPath.FieldPath());
			}
		}
		public SodaQueryComparator(LocalObjectContainer container, ClassMetadata extent, 
			SodaQueryComparator.Ordering[] orderings)
		{
			_container = container;
			_transaction = ((LocalTransaction)_container.Transaction);
			_extentType = extent;
			_orderings = orderings;
			ResolveFieldPaths(orderings);
		}
Exemplo n.º 7
0
		protected void AddOrdering(SodaQueryComparator.Direction direction, IList path)
		{
			if (i_field != null)
			{
				path.Add(i_field);
			}
			if (i_parent != null)
			{
				i_parent.AddOrdering(direction, path);
				return;
			}
			string[] fieldPath = ReverseFieldPath(path);
			RemoveExistingOrderingFor(fieldPath);
			Orderings().Add(new SodaQueryComparator.Ordering(direction, fieldPath));
		}
Exemplo n.º 8
0
		private void AddOrdering(SodaQueryComparator.Direction direction)
		{
			AddOrdering(direction, new ArrayList());
		}