当前位置: 首页>>代码示例>>C#>>正文


C# IQuery.Execute方法代码示例

本文整理汇总了C#中IQuery.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# IQuery.Execute方法的具体用法?C# IQuery.Execute怎么用?C# IQuery.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IQuery的用法示例。


在下文中一共展示了IQuery.Execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Expect

		public static void Expect(IQuery query, object[] results, bool ordered)
		{
			IObjectSet set = query.Execute();
			if (results == null || results.Length == 0)
			{
				if (set.Count > 0)
				{
					Assert.Fail("No content expected.");
				}
				return;
			}
			int j = 0;
			Assert.AreEqual(results.Length, set.Count);
			while (set.HasNext())
			{
				object obj = set.Next();
				bool found = false;
				if (ordered)
				{
					if (TCompare.IsEqual(results[j], obj))
					{
						results[j] = null;
						found = true;
					}
					j++;
				}
				else
				{
					for (int i = 0; i < results.Length; i++)
					{
						if (results[i] != null)
						{
							if (TCompare.IsEqual(results[i], obj))
							{
								results[i] = null;
								found = true;
								break;
							}
						}
					}
				}
				if (ordered)
				{
					Assert.IsTrue(found, "Expected '" + SafeToString(results[j - 1]) + "' but got '" 
						+ SafeToString(obj) + "' at index " + (j - 1));
				}
				else
				{
					Assert.IsTrue(found, "Object not expected: " + SafeToString(obj));
				}
			}
			for (int i = 0; i < results.Length; i++)
			{
				if (results[i] != null)
				{
					Assert.Fail("Expected object not returned: " + results[i]);
				}
			}
		}
开发者ID:erdincay,项目名称:db4o,代码行数:59,代码来源:SodaTestUtil.cs

示例2: AssertSingleElementQueryResult

 private void AssertSingleElementQueryResult(IQuery query, object element)
 {
     var objectSet = query.Execute();
     Assert.AreEqual(1, objectSet.Count);
     var item = (Item) objectSet.Next(
         );
     Assert.AreEqual(element, item.list[0]);
 }
开发者ID:masroore,项目名称:db4o,代码行数:8,代码来源:SimpleListQueryTestCase.cs

示例3: Concat

        public IQuery Concat(IQuery operacion1, IQuery operacion2, TypeOperators typeOperator)
        {
            var value=string.Empty;
            switch (typeOperator)
            {
                case TypeOperators.And:
                    value = (string.Format("<And>{0}{1}</And>", operacion1.Execute(), operacion2.Execute()));
                    break;
                case TypeOperators.Or:
                default:
                    value = (string.Format("<Or>{0}{1}</Or>", operacion1.Execute(), operacion2.Execute()));
                    break;              
            }
            query = string.IsNullOrEmpty(query) ? value : query.Replace("{0}", value);

            return new Query
            {
                query = query
            };
        }
开发者ID:4lbertoG,项目名称:Enmarcha-SharePoint,代码行数:20,代码来源:Query.cs

示例4: AssertBatchBehaviorFor

 private void AssertBatchBehaviorFor(IQuery query, int expectedMessageCount)
 {
     var result = query.Execute();
     var messages = MessageCollector.ForServerDispatcher(ServerDispatcher());
     Assert.AreEqual("foo", ((Item) result
         .Next()).name);
     Assert.AreEqual(expectedMessageCount, messages.Count, messages.ToString());
 }
开发者ID:masroore,项目名称:db4o,代码行数:8,代码来源:BatchActivationTestCase.cs

示例5: AssertSingleElementQueryResult

		private void AssertSingleElementQueryResult(IQuery query, object element)
		{
			IObjectSet objectSet = query.Execute();
			Assert.AreEqual(1, objectSet.Count);
			SimpleListQueryTestCase.Item item = (SimpleListQueryTestCase.Item)objectSet.Next(
				);
			Assert.AreEqual(element, item.list[0]);
		}
开发者ID:superyfwy,项目名称:db4o,代码行数:8,代码来源:SimpleListQueryTestCase.cs

示例6: AssertIdOrder

		private void AssertIdOrder(IQuery query, IQueryComparator comparator, int[] ids)
		{
			query.SortBy(comparator);
			IObjectSet result = query.Execute();
			AssertIdOrder(result, ids);
		}
开发者ID:erdincay,项目名称:db4o,代码行数:6,代码来源:ComparatorSortTestCase.cs

示例7: QueryForItem

 private Item QueryForItem(IQuery q, int n)
 {
     q.Constrain(typeof (Item));
     q.Descend("_name").Constrain("item" + n);
     return (Item) q.Execute().Next();
 }
开发者ID:masroore,项目名称:db4o,代码行数:6,代码来源:IxFreespaceMigrationTestCase.cs

示例8: AssertSuccessfulQueryResult

		protected void AssertSuccessfulQueryResult(IQuery q)
		{
			IObjectSet set = q.Execute();
			Assert.AreEqual(1, set.Count);

			_helper.AssertCollection(set.Next());
		}
开发者ID:Galigator,项目名称:db4o,代码行数:7,代码来源:GenericCollectionTypeHandlerTestUnitBase.cs

示例9: AssertBatchBehaviorFor

			private void AssertBatchBehaviorFor(IQuery query, int expectedMessageCount)
			{
				IObjectSet result = query.Execute();
				IList messages = MessageCollector.ForServerDispatcher(ServerDispatcher());
				Assert.AreEqual("foo", ((BatchActivationTestCase.BatchActivationTestUnit.Item)result
					.Next()).name);
				Assert.AreEqual(expectedMessageCount, messages.Count, messages.ToString());
			}
开发者ID:erdincay,项目名称:db4o,代码行数:8,代码来源:BatchActivationTestCase.cs

示例10: TExpectInts

 private void TExpectInts(IQuery q, int[] ints, int zeroSize)
 {
     var res = q.Execute();
     Assert.AreEqual(ints.Length + zeroSize, res.Count);
     while (res.HasNext())
     {
         var ci = (CreateIndexFor
             ) res.Next();
         for (var i = 0; i < ints.Length; i++)
         {
             if (ints[i] == ci.i_int)
             {
                 ints[i] = 0;
                 break;
             }
         }
     }
     for (var i = 0; i < ints.Length; i++)
     {
         Assert.AreEqual(0, ints[i]);
     }
 }
开发者ID:masroore,项目名称:db4o,代码行数:22,代码来源:CreateIndexInheritedTestCase.cs

示例11: AssertSuccessfulQueryResult

 private void AssertSuccessfulQueryResult(IQuery q)
 {
     var set = q.Execute();
     Assert.AreEqual(1, set.Count);
     var item = set.Next();
     AssertContent(item);
 }
开发者ID:masroore,项目名称:db4o,代码行数:7,代码来源:TypeHandlerTestUnitBase.cs

示例12: AssertEmptyQueryResult

 private void AssertEmptyQueryResult(IQuery q)
 {
     var set = q.Execute();
     Assert.AreEqual(0, set.Count);
 }
开发者ID:masroore,项目名称:db4o,代码行数:5,代码来源:TypeHandlerTestUnitBase.cs

示例13: MapToObjectIds

 protected virtual int[] MapToObjectIds(IQuery itemQuery, int[] foos)
 {
     var trans = TransactionFromQuery(itemQuery);
     var lookingFor = IntArrays4.Clone(foos);
     var objectIds = new int[foos.Length];
     var set = itemQuery.Execute();
     while (set.HasNext())
     {
         var item = (IHasFoo) set.Next();
         for (var i = 0; i < lookingFor.Length; i++)
         {
             if (lookingFor[i] == item.GetFoo())
             {
                 lookingFor[i] = -1;
                 objectIds[i] = ((ObjectContainerBase) Db()).GetID(trans, item);
                 break;
             }
         }
     }
     var index = IndexOfNot(lookingFor, -1);
     if (-1 != index)
     {
         throw new ArgumentException("Foo '" + lookingFor[index] + "' not found!");
     }
     return objectIds;
 }
开发者ID:masroore,项目名称:db4o,代码行数:26,代码来源:FieldIndexProcessorTestCaseBase.cs

示例14: AssertQuerySize

 private void AssertQuerySize(int size, IQuery q)
 {
     Assert.AreEqual(size, q.Execute().Count);
 }
开发者ID:masroore,项目名称:db4o,代码行数:4,代码来源:IndexCreateDropTestCase.cs

示例15: QueryForItem

		private IxFreespaceMigrationTestCase.Item QueryForItem(IQuery q, int n)
		{
			q.Constrain(typeof(IxFreespaceMigrationTestCase.Item));
			q.Descend("_name").Constrain("item" + n);
			return (IxFreespaceMigrationTestCase.Item)q.Execute().Next();
		}
开发者ID:bvangrinsven,项目名称:db4o-net,代码行数:6,代码来源:IxFreespaceMigrationTestCase.cs


注:本文中的IQuery.Execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。