本文整理汇总了C#中SimpleResultSet类的典型用法代码示例。如果您正苦于以下问题:C# SimpleResultSet类的具体用法?C# SimpleResultSet怎么用?C# SimpleResultSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleResultSet类属于命名空间,在下文中一共展示了SimpleResultSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestOfType
public void TestOfType()
{
dynamic test = new SimpleResultSet(new dynamic[] { "Hello", 1 });
IEnumerable<int> ints = test.OfType<int>();
Assert.AreEqual(1, ints.Count());
Assert.AreEqual(1, ints.Single());
}
示例2: TryGetMember
public override bool TryGetMember(GetMemberBinder binder, out object result)
{
if (_data.ContainsKey(binder.Name))
{
result = _data[binder.Name];
var converted = ConvertResult(result);
if (!ReferenceEquals(result, converted))
_data[binder.Name] = result = converted;
return true;
}
if (_tableName == null)
{
result = null;
return false;
}
var relatedAdapter = _database.Adapter as IAdapterWithRelation;
if (relatedAdapter != null && relatedAdapter.IsValidRelation(_tableName, binder.Name))
{
var relatedRows = relatedAdapter.FindRelated(_tableName, _data, binder.Name);
if (relatedRows.Count() == 1 && !binder.Name.IsPlural())
{
result = new SimpleRecord(relatedRows.Single(), binder.Name, _database);
}
else
{
result = new SimpleResultSet(relatedRows.Select(dict => new SimpleRecord(dict, binder.Name, _database)));
}
return true;
}
return base.TryGetMember(binder, out result);
}
示例3: TestCastWithClass
public void TestCastWithClass()
{
var dict = new Dictionary<string, object> {{"Name", "Bob"}};
dynamic test = new SimpleResultSet(new[] {new SimpleRecord(dict)});
IEnumerable<Foo> foos = test.Cast<Foo>();
Assert.AreEqual(1, foos.Count());
}
示例4: TestCastWithForeach
public void TestCastWithForeach()
{
var dict = new Dictionary<string, object> { { "Name", "Bob" } };
dynamic test = new SimpleResultSet(new[] { new SimpleRecord(dict) });
foreach (Foo foo in test)
{
Assert.AreEqual("Bob", foo.Name);
}
}
示例5: TestCastWithForeach
public void TestCastWithForeach()
{
var dict = new Dictionary<string, object>(HomogenizedEqualityComparer.DefaultInstance) { { "Name", "Bob" } };
dynamic test = new SimpleResultSet(new[] { new SimpleRecord(dict) });
foreach (Foo foo in test)
{
Assert.AreEqual("Bob", foo.Name);
}
}
示例6: LastOrDefaultReturnsLastElement
public void LastOrDefaultReturnsLastElement()
{
var list = new SimpleResultSet(Records(10));
Assert.AreEqual("9", list.LastOrDefault().Data);
}
示例7: FirstOrDefaultWithFailingCriteriaReturnsNull
public void FirstOrDefaultWithFailingCriteriaReturnsNull()
{
var list = new SimpleResultSet(Records(20));
Assert.IsNull(list.FirstOrDefault<TestType>(t => t.Data.EndsWith("A")));
}
示例8: FirstWithFailingCriteriaThrows
public void FirstWithFailingCriteriaThrows()
{
var list = new SimpleResultSet(Records(20));
Assert.Throws<InvalidOperationException>(() => list.First<TestType>(t => t.Data.EndsWith("A")));
}
示例9: ToGenericListCreatesTypedList
public void ToGenericListCreatesTypedList()
{
dynamic list = new SimpleResultSet(Records(1));
List<TestType> converted = list.ToList<TestType>();
Assert.IsNotNull(converted);
Assert.AreEqual(1, converted.Count);
Assert.AreEqual("0", converted[0].Data);
}
示例10: ToGenericArrayCreatesTypedArray
public void ToGenericArrayCreatesTypedArray()
{
dynamic list = new SimpleResultSet(Records(1));
TestType[] array = list.ToArray<TestType>();
Assert.IsNotNull(array);
Assert.AreEqual(1, array.Length);
Assert.AreEqual("0", array[0].Data);
}
示例11: ConvertsToHashSet
public void ConvertsToHashSet()
{
dynamic list = new SimpleResultSet(Records(1));
HashSet<dynamic> generic = list;
Assert.IsNotNull(generic);
Assert.AreEqual("0", generic.Single().Data);
}
示例12: FirstReturnsFirstElement
public void FirstReturnsFirstElement()
{
var list = new SimpleResultSet(Records(10));
Assert.AreEqual("0", list.First().Data);
}
示例13: SingleWithCriteriaMatchingOneRecordReturnsMatch
public void SingleWithCriteriaMatchingOneRecordReturnsMatch()
{
var list = new SimpleResultSet(Records(10));
Assert.AreEqual("8", list.Single<TestType>(t => t.Data.EndsWith("8")).Data);
}
示例14: SingleThrowsOnListWithMoreThanOneElement
public void SingleThrowsOnListWithMoreThanOneElement()
{
var list = new SimpleResultSet(Records(2));
Assert.Throws<InvalidOperationException>(() => list.Single());
}
示例15: SingleReturnsSingleElement
public void SingleReturnsSingleElement()
{
var list = new SimpleResultSet(Records(1));
Assert.AreEqual("0", list.Single().Data);
}