本文整理汇总了C#中Mono.Data.Sqlite.Orm.Tests.OrmTestSession.CreateTable方法的典型用法代码示例。如果您正苦于以下问题:C# OrmTestSession.CreateTable方法的具体用法?C# OrmTestSession.CreateTable怎么用?C# OrmTestSession.CreateTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Data.Sqlite.Orm.Tests.OrmTestSession
的用法示例。
在下文中一共展示了OrmTestSession.CreateTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Collate
public void Collate()
{
var obj = new TestObj
{
CollateDefault = "Alpha ",
CollateBinary = "Alpha ",
CollateRTrim = "Alpha ",
CollateNoCase = "Alpha ",
};
var db = new OrmTestSession();
db.CreateTable<TestObj>();
db.Insert(obj);
Assert.AreEqual(1, (from o in db.Table<TestObj>() where o.CollateDefault == "Alpha " select o).Count());
Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateDefault == "ALPHA " select o).Count());
Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateDefault == "Alpha" select o).Count());
Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateDefault == "ALPHA" select o).Count());
Assert.AreEqual(1, (from o in db.Table<TestObj>() where o.CollateBinary == "Alpha " select o).Count());
Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateBinary == "ALPHA " select o).Count());
Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateBinary == "Alpha" select o).Count());
Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateBinary == "ALPHA" select o).Count());
Assert.AreEqual(1, (from o in db.Table<TestObj>() where o.CollateRTrim == "Alpha " select o).Count());
Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateRTrim == "ALPHA " select o).Count());
Assert.AreEqual(1, (from o in db.Table<TestObj>() where o.CollateRTrim == "Alpha" select o).Count());
Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateRTrim == "ALPHA" select o).Count());
Assert.AreEqual(1, (from o in db.Table<TestObj>() where o.CollateNoCase == "Alpha " select o).Count());
Assert.AreEqual(1, (from o in db.Table<TestObj>() where o.CollateNoCase == "ALPHA " select o).Count());
Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateNoCase == "Alpha" select o).Count());
Assert.AreEqual(0, (from o in db.Table<TestObj>() where o.CollateNoCase == "ALPHA" select o).Count());
}
示例2: CreateInsertDrop
public void CreateInsertDrop()
{
var db = new OrmTestSession();
db.CreateTable<Product>();
db.Insert(new Product
{
Name = "Hello",
Price = 16,
});
int n = db.Table<Product>().Count();
Assert.AreEqual(1, n);
db.DropTable<Product>();
try
{
// Should throw SqliteException
db.Table<Product>().Count();
Assert.Fail("Expeced 'table does not exist' error.");
}
catch (SqliteException)
{
}
catch
{
Assert.Fail();
}
}
示例3: Skip
public void Skip()
{
var db = new OrmTestSession();
db.CreateTable<TestObj>();
const int n = 100;
IEnumerable<TestObj> cq = from i in Enumerable.Range(1, n)
select new TestObj
{
Order = i
};
TestObj[] objs = cq.ToArray();
int numIn = db.InsertAll(objs);
Assert.AreEqual(numIn, n, "Num inserted must = num objects");
TableQuery<TestObj> q = from o in db.Table<TestObj>()
orderby o.Order
select o;
TableQuery<TestObj> qs1 = q.Skip(1);
List<TestObj> s1 = qs1.ToList();
Assert.AreEqual(n - 1, s1.Count);
Assert.AreEqual(2, s1[0].Order);
TableQuery<TestObj> qs5 = q.Skip(5);
List<TestObj> s5 = qs5.ToList();
Assert.AreEqual(n - 5, s5.Count);
Assert.AreEqual(6, s5[0].Order);
}
示例4: 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());
}
}
示例5: ClearTableTest
public void ClearTableTest()
{
// setup
var db = new OrmTestSession();
db.CreateTable<Product>();
// insert
db.Insert(new Product { Name = "Hello", Price = 16, });
db.Insert(new Product { Name = "Hello", Price = 16, });
// confirm
Assert.AreEqual(2, db.Table<Product>().Count());
db.Get<Product>(1);
// clear
Assert.AreEqual(2, db.ClearTable<Product>());
// confirm
Assert.AreEqual(0, db.Table<Product>().Count());
// insert
db.Insert(new Product { Name = "Hello", Price = 16, });
// confirm that the Ids have not reset
Assert.AreEqual(1, db.Table<Product>().Count());
db.Get<Product>(3);
}
示例6: CreateUnknownColumnType
public void CreateUnknownColumnType()
{
using (var db = new OrmTestSession())
{
ExceptionAssert.Throws<NotSupportedException>(() => db.CreateTable<UnknownColumnType>());
}
}
示例7: DropTableUsingSqlString
public void DropTableUsingSqlString()
{
var db = new OrmTestSession();
db.CreateTable<Product>();
var results = db.Execute("DROP TABLE IF EXISTS Product;");
}
示例8: EnsureSimpleTableExistsUsingQuery
public void EnsureSimpleTableExistsUsingQuery()
{
using (var db = new OrmTestSession())
{
db.CreateTable<SimpleTable>();
Assert.AreEqual(0, db.ExecuteScalar<int>("SELECT COUNT(*) FROM [SimpleTable];"));
}
}
示例9: EnsureSimpleTableExistsUsingTableExists
public void EnsureSimpleTableExistsUsingTableExists()
{
using (var db = new OrmTestSession())
{
db.CreateTable<SimpleTable>();
Assert.IsTrue(db.TableExists<SimpleTable>());
}
}
示例10: MergeTest
public void MergeTest()
{
using (var db = new OrmTestSession())
{
db.CreateTable<SimpleTable>();
db.Insert(new SimpleTable { Name = RandomString() });
db.Merge<SimpleTable>();
}
}
示例11: RunMergeUntilOptimalTest
public void RunMergeUntilOptimalTest()
{
using (var db = new OrmTestSession())
{
db.CreateTable<SimpleTable>();
db.Insert(new SimpleTable { Name = RandomString() });
db.RunMergeUntilOptimal<SimpleTable>();
}
}
示例12: CreateInstanceHookTest
public void CreateInstanceHookTest()
{
var db = new OrmTestSession();
db.InstanceCreated += InstanceCreated;
db.CreateTable<HookTestTable>();
db.Insert(new HookTestTable { Text = InsertedTest });
var got = db.Get<HookTestTable>(1);
Assert.AreEqual(ReplacedText, got.Text);
}
示例13: IntegrityCheckTest
public void IntegrityCheckTest()
{
using (var db = new OrmTestSession())
{
db.CreateTable<SimpleTable>();
db.Insert(new SimpleTable { Name = RandomString() });
db.IntegrityCheck<SimpleTable>();
}
}
示例14: CreateInstanceHookTestNonGeneric
public void CreateInstanceHookTestNonGeneric()
{
var db = new OrmTestSession();
db.InstanceCreated += InstanceCreated;
db.CreateTable<HookTestTable>();
db.Insert(new HookTestTable { Text = InsertedTest });
var got = db.Get(typeof(HookTestTable), 1);
Assert.AreEqual(ReplacedText, ((HookTestTable)got).Text);
}
示例15: CreateThem
public void CreateThem()
{
var db = new OrmTestSession();
db.CreateTable<Product>();
db.CreateTable<OrderLine>();
var foo = new Product { Name = "Foo", Price = 10.0m };
var bar = new Product { Name = "Bar", Price = 0.10m };
db.Insert(foo);
db.Insert(bar);
db.Insert(new OrderLine { ProductId = foo.Id, Quantity = 6, UnitPrice = 10.01m });
db.Insert(new OrderLine { ProductId = foo.Id, Quantity = 3, UnitPrice = 0.02m });
db.Insert(new OrderLine { ProductId = bar.Id, Quantity = 9, UnitPrice = 100.01m });
OrderLine[] lines = foo.OrderLines;
Assert.AreEqual(lines.Length, 2, "Has 2 order lines");
Assert.AreEqual(foo.Connection, db, "foo.Connection was set");
Assert.AreEqual(lines[0].Connection, db, "lines[0].Connection was set");
}