本文整理汇总了C#中Mono.Data.Sqlite.Orm.Tests.OrmTestSession.Query方法的典型用法代码示例。如果您正苦于以下问题:C# OrmTestSession.Query方法的具体用法?C# OrmTestSession.Query怎么用?C# OrmTestSession.Query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Data.Sqlite.Orm.Tests.OrmTestSession
的用法示例。
在下文中一共展示了OrmTestSession.Query方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestBoolean
public void TestBoolean()
{
var db = new OrmTestSession();
db.CreateTable<Vo>();
for (int i = 0; i < 10; i++)
{
db.Insert(new Vo {Flag = (i%3 == 0), Text = String.Format("VO{0}", i)});
}
// count vo which flag is true
Assert.AreEqual(4, CountWithFlag(db, true));
Assert.AreEqual(6, CountWithFlag(db, false));
Debug.WriteLine("VO with true flag:");
foreach (Vo vo in db.Query<Vo>("SELECT * FROM VO Where Flag = ?", true))
{
Debug.WriteLine(vo.ToString());
}
Debug.WriteLine("VO with false flag:");
foreach (Vo vo in db.Query<Vo>("SELECT * FROM VO Where Flag = ?", false))
{
Debug.WriteLine(vo.ToString());
}
}
示例2: Unicode
public void Unicode()
{
var insertItem = new TestObj { Text = "Sinéad O'Connor" };
var db = new OrmTestSession();
db.CreateTable<TestObj>();
int numIn = db.Insert(insertItem);
Assert.AreEqual(numIn, 1, "Num inserted must = num objects");
TestObj inObjs = db.Query<TestObj>("select * from TestObj").First();
Assert.AreEqual(insertItem.Text, inObjs.Text);
}
示例3: InsertTwoTimes
public void InsertTwoTimes()
{
var db = new OrmTestSession();
db.CreateTable<TestObj>();
var obj1 = new TestObj { Text = "GLaDOS loves testing!" };
var obj2 = new TestObj { Text = "Keep testing, just keep testing" };
int numIn1 = db.Insert(obj1);
int numIn2 = db.Insert(obj2);
Assert.AreEqual(1, numIn1);
Assert.AreEqual(1, numIn2);
List<TestObj> 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);
db.Close();
}
示例4: InsertWithExtra
public void InsertWithExtra()
{
var db = new OrmTestSession();
db.CreateTable<TestObj2>();
var obj1 = new TestObj2 { Id = 1, Text = "GLaDOS loves testing!" };
var obj2 = new TestObj2 { Id = 1, Text = "Keep testing, just keep testing" };
var obj3 = new TestObj2 { Id = 1, Text = "Done testing" };
db.Insert(obj1);
// "Expected unique constraint violation"
ExceptionAssert.Throws<SqliteException>(() => db.Insert(obj2));
db.Insert(obj2, ConflictResolution.Replace);
// "Expected unique constraint violation"
ExceptionAssert.Throws<SqliteException>(() => db.Insert(obj3));
db.Insert(obj3, ConflictResolution.Ignore);
List<TestObj> result = db.Query<TestObj>("select * from TestObj2").ToList();
Assert.AreEqual(1, result.Count);
Assert.AreEqual(obj2.Text, result.First().Text);
db.Close();
}
示例5: InsertIntoTwoTables
public void InsertIntoTwoTables()
{
var db = new OrmTestSession();
db.CreateTable<TestObj>();
db.CreateTable<TestObj2>();
var obj1 = new TestObj { Text = "GLaDOS loves testing!" };
var obj2 = new TestObj2 { Text = "Keep testing, just keep testing" };
int numIn1 = db.Insert(obj1);
Assert.AreEqual(1, numIn1);
int numIn2 = db.Insert(obj2);
Assert.AreEqual(1, numIn2);
List<TestObj> result1 = db.Table<TestObj>().ToList();
Assert.AreEqual(numIn1, result1.Count);
Assert.AreEqual(obj1.Text, result1.First().Text);
List<TestObj> result2 = db.Query<TestObj>("select * from TestObj2").ToList();
Assert.AreEqual(numIn2, result2.Count);
db.Close();
}