本文整理汇总了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");
}
}
示例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));
}
}
示例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();
}
示例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();
}