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


C# SimpleResultSet类代码示例

本文整理汇总了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());
 }
开发者ID:dezfowler,项目名称:Simple.Data,代码行数:7,代码来源:DynamicEnumerableTest.cs

示例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);
        }
开发者ID:robashton,项目名称:Simple.Data,代码行数:33,代码来源:SimpleRecord.cs

示例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());
 }
开发者ID:dezfowler,项目名称:Simple.Data,代码行数:7,代码来源:DynamicEnumerableTest.cs

示例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);
     }
 }
开发者ID:dezfowler,项目名称:Simple.Data,代码行数:9,代码来源:DynamicEnumerableTest.cs

示例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);
     }
 }
开发者ID:JorgeGamba,项目名称:Simple.Data,代码行数:9,代码来源:DynamicEnumerableTest.cs

示例6: LastOrDefaultReturnsLastElement

 public void LastOrDefaultReturnsLastElement()
 {
     var list = new SimpleResultSet(Records(10));
     Assert.AreEqual("9", list.LastOrDefault().Data);
 }
开发者ID:rposbo,项目名称:Simple.Data,代码行数:5,代码来源:SimpleResultSetTest.cs

示例7: FirstOrDefaultWithFailingCriteriaReturnsNull

 public void FirstOrDefaultWithFailingCriteriaReturnsNull()
 {
     var list = new SimpleResultSet(Records(20));
     Assert.IsNull(list.FirstOrDefault<TestType>(t => t.Data.EndsWith("A")));
 }
开发者ID:rposbo,项目名称:Simple.Data,代码行数:5,代码来源:SimpleResultSetTest.cs

示例8: FirstWithFailingCriteriaThrows

 public void FirstWithFailingCriteriaThrows()
 {
     var list = new SimpleResultSet(Records(20));
     Assert.Throws<InvalidOperationException>(() => list.First<TestType>(t => t.Data.EndsWith("A")));
 }
开发者ID:rposbo,项目名称:Simple.Data,代码行数:5,代码来源:SimpleResultSetTest.cs

示例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);
        }
开发者ID:rposbo,项目名称:Simple.Data,代码行数:9,代码来源:SimpleResultSetTest.cs

示例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);
        }
开发者ID:rposbo,项目名称:Simple.Data,代码行数:9,代码来源:SimpleResultSetTest.cs

示例11: ConvertsToHashSet

 public void ConvertsToHashSet()
 {
     dynamic list = new SimpleResultSet(Records(1));
     HashSet<dynamic> generic = list;
     Assert.IsNotNull(generic);
     Assert.AreEqual("0", generic.Single().Data);
 } 
开发者ID:rposbo,项目名称:Simple.Data,代码行数:7,代码来源:SimpleResultSetTest.cs

示例12: FirstReturnsFirstElement

 public void FirstReturnsFirstElement()
 {
     var list = new SimpleResultSet(Records(10));
     Assert.AreEqual("0", list.First().Data);
 }
开发者ID:rposbo,项目名称:Simple.Data,代码行数:5,代码来源:SimpleResultSetTest.cs

示例13: SingleWithCriteriaMatchingOneRecordReturnsMatch

 public void SingleWithCriteriaMatchingOneRecordReturnsMatch()
 {
     var list = new SimpleResultSet(Records(10));
     Assert.AreEqual("8", list.Single<TestType>(t => t.Data.EndsWith("8")).Data);
 }
开发者ID:rposbo,项目名称:Simple.Data,代码行数:5,代码来源:SimpleResultSetTest.cs

示例14: SingleThrowsOnListWithMoreThanOneElement

 public void SingleThrowsOnListWithMoreThanOneElement()
 {
     var list = new SimpleResultSet(Records(2));
     Assert.Throws<InvalidOperationException>(() => list.Single());
 }
开发者ID:rposbo,项目名称:Simple.Data,代码行数:5,代码来源:SimpleResultSetTest.cs

示例15: SingleReturnsSingleElement

 public void SingleReturnsSingleElement()
 {
     var list = new SimpleResultSet(Records(1));
     Assert.AreEqual("0", list.Single().Data);
 }
开发者ID:rposbo,项目名称:Simple.Data,代码行数:5,代码来源:SimpleResultSetTest.cs


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