本文整理汇总了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]);
}
}
}
示例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]);
}
示例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
};
}
示例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());
}
示例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]);
}
示例6: AssertIdOrder
private void AssertIdOrder(IQuery query, IQueryComparator comparator, int[] ids)
{
query.SortBy(comparator);
IObjectSet result = query.Execute();
AssertIdOrder(result, ids);
}
示例7: QueryForItem
private Item QueryForItem(IQuery q, int n)
{
q.Constrain(typeof (Item));
q.Descend("_name").Constrain("item" + n);
return (Item) q.Execute().Next();
}
示例8: AssertSuccessfulQueryResult
protected void AssertSuccessfulQueryResult(IQuery q)
{
IObjectSet set = q.Execute();
Assert.AreEqual(1, set.Count);
_helper.AssertCollection(set.Next());
}
示例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());
}
示例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]);
}
}
示例11: AssertSuccessfulQueryResult
private void AssertSuccessfulQueryResult(IQuery q)
{
var set = q.Execute();
Assert.AreEqual(1, set.Count);
var item = set.Next();
AssertContent(item);
}
示例12: AssertEmptyQueryResult
private void AssertEmptyQueryResult(IQuery q)
{
var set = q.Execute();
Assert.AreEqual(0, set.Count);
}
示例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;
}
示例14: AssertQuerySize
private void AssertQuerySize(int size, IQuery q)
{
Assert.AreEqual(size, q.Execute().Count);
}
示例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();
}