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


C# TestDb.Query方法代码示例

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


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

示例1: CreateUniqueIndexes

 public void CreateUniqueIndexes()
 {
     using (var db = new TestDb ()) {
         db.CreateTable<TheOne> ();
         var indexes = db.Query<IndexInfo> ("PRAGMA INDEX_LIST (\"TheOne\")");
         Assert.AreEqual (4, indexes.Count, "# of indexes");
         CheckIndex (db, indexes, "UX_Uno", true, "Uno");
         CheckIndex (db, indexes, "UX_Dos", true, "Dos", "Tres");
         CheckIndex (db, indexes, "UX_Uno_bool", true, "Cuatro");
         CheckIndex (db, indexes, "UX_Dos_bool", true, "Cinco", "Seis");
     }
 }
开发者ID:Toshik,项目名称:sqlite-net,代码行数:12,代码来源:UniqueTest.cs

示例2: CheckIndex

 static void CheckIndex(TestDb db, List<IndexInfo> indexes, string iname, bool unique, params string [] columns)
 {
     if (columns == null)
         throw new Exception ("Don't!");
     var idx = indexes.SingleOrDefault (i => i.name == iname);
     Assert.IsNotNull (idx, String.Format ("Index {0} not found", iname));
     Assert.AreEqual (idx.unique, unique, String.Format ("Index {0} unique expected {1} but got {2}", iname, unique, idx.unique));
     var idx_columns = db.Query<IndexColumns> (String.Format ("PRAGMA INDEX_INFO (\"{0}\")", iname));
     Assert.AreEqual (columns.Length, idx_columns.Count, String.Format ("# of columns: expected {0}, got {1}", columns.Length, idx_columns.Count));
     foreach (var col in columns) {
         Assert.IsNotNull (idx_columns.SingleOrDefault (c => c.name == col), String.Format ("Column {0} not in index {1}", col, idx.name));
     }
 }
开发者ID:Toshik,项目名称:sqlite-net,代码行数:13,代码来源:UniqueTest.cs

示例3: ShouldPersistAndReadGuid

        public void ShouldPersistAndReadGuid() {
            var db = new TestDb(TestPath.GetTempFileName());

            var obj1 = new TestObj() { Id=new Guid("36473164-C9E4-4CDF-B266-A0B287C85623"), Text = "First Guid Object" };
            var obj2 = new TestObj() {  Id=new Guid("BC5C4C4A-CA57-4B61-8B53-9FD4673528B6"), Text = "Second Guid Object" };

            var numIn1 = db.Insert(obj1);
            var numIn2 = db.Insert(obj2);
            Assert.AreEqual(1, numIn1);
            Assert.AreEqual(1, numIn2);

            var result = db.Query<TestObj>("select * from TestObj").ToList();
            Assert.AreEqual(2, result.Count);
            Assert.AreEqual(obj1.Text, result[0].Text);
            Assert.AreEqual(obj2.Text, result[1].Text);

            Assert.AreEqual(obj1.Id, result[0].Id);
            Assert.AreEqual(obj2.Id, result[1].Id);

            db.Close();
        }
开发者ID:hyres88,项目名称:field-service-example,代码行数:21,代码来源:GuidTests.cs

示例4: ShouldPersistAndReadEnum

        public void ShouldPersistAndReadEnum()
        {
            var db = new TestDb(TestPath.GetTempFileName());

            var obj1 = new TestObj() { Id = 1, Value = TestEnum.Value2 };
            var obj2 = new TestObj() { Id = 2, Value = TestEnum.Value3 };

            var numIn1 = db.Insert(obj1);
            var numIn2 = db.Insert(obj2);
            Assert.AreEqual(1, numIn1);
            Assert.AreEqual(1, numIn2);

            var result = db.Query<TestObj>("select * from TestObj").ToList();
            Assert.AreEqual(2, result.Count);
            Assert.AreEqual(obj1.Value, result[0].Value);
            Assert.AreEqual(obj2.Value, result[1].Value);

            Assert.AreEqual(obj1.Id, result[0].Id);
            Assert.AreEqual(obj2.Id, result[1].Id);

            db.Close();
        }
开发者ID:praeclarum,项目名称:sqlite-net,代码行数:22,代码来源:EnumTest.cs


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