本文整理汇总了C#中SQLite.Tests.TestDb.CreateTable方法的典型用法代码示例。如果您正苦于以下问题:C# TestDb.CreateTable方法的具体用法?C# TestDb.CreateTable怎么用?C# TestDb.CreateTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLite.Tests.TestDb
的用法示例。
在下文中一共展示了TestDb.CreateTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public void SetUp()
{
_db = new TestDb();
_db.CreateTable<Product>();
_db.CreateTable<Order>();
_db.CreateTable<OrderLine>();
var p1 = new Product { Name = "One", };
var p2 = new Product { Name = "Two", };
var p3 = new Product { Name = "Three", };
_db.InsertAll(new[] { p1, p2, p3 });
var o1 = new Order { PlacedTime = DateTime.Now, };
var o2 = new Order { PlacedTime = DateTime.Now, };
_db.InsertAll(new[] { o1, o2 });
_db.InsertAll(new[] {
new OrderLine {
OrderId = o1.Id,
ProductId = p1.Id,
Quantity = 1,
},
new OrderLine {
OrderId = o1.Id,
ProductId = p2.Id,
Quantity = 2,
},
new OrderLine {
OrderId = o2.Id,
ProductId = p3.Id,
Quantity = 3,
},
});
}
示例2: CreateDb
TestDb CreateDb()
{
var db = new TestDb ();
db.CreateTable<Product> ();
db.CreateTable<Order> ();
db.CreateTable<OrderLine> ();
db.CreateTable<OrderHistory> ();
return db;
}
示例3: UpperAndLowerColumnNames
public void UpperAndLowerColumnNames()
{
using (var db = new TestDb (true) { Trace = true } ) {
db.CreateTable<LowerId> ();
db.CreateTable<UpperId> ();
var cols = db.GetTableInfo ("Test").ToList ();
Assert.AreEqual (1, cols.Count);
Assert.AreEqual ("Id", cols[0].Name);
}
}
示例4: CreateThem
public void CreateThem ()
{
var db = new TestDb ();
db.CreateTable<Product> ();
db.CreateTable<Order> ();
db.CreateTable<OrderLine> ();
db.CreateTable<OrderHistory> ();
VerifyCreations(db);
}
示例5: UpperAndLowerColumnNames
public void UpperAndLowerColumnNames()
{
using (var db = new TestDb (true) { Trace = true } ) {
db.CreateTable<LowerId> ();
db.CreateTable<UpperId> ();
var cols = db.GetTableInfo ("Test").ToList ();
Assert.That (cols.Count, Is.EqualTo (1));
Assert.That (cols[0].Name, Is.EqualTo ("Id"));
}
}
示例6: CreateAsPassedInTypes
public void CreateAsPassedInTypes ()
{
var db = new TestDb();
db.CreateTable(typeof(Product));
db.CreateTable(typeof(Order));
db.CreateTable(typeof(OrderLine));
db.CreateTable(typeof(OrderHistory));
VerifyCreations(db);
}
示例7: CreateDbWithOne2Many
SQLiteConnection CreateDbWithOne2Many ()
{
var db = new TestDb ()
.SetForeignKeysPermissions(true);
db.CreateTable<TestObjWithOne2Many> ();
db.CreateTable<TestDependentObj> ();
var items = Enumerable.Range(1,parentCount)
.Select(i => new TestObjWithOne2Many {Id = i,
ObjList = Enumerable.Range(1,childCount)
.Select(x => new TestDependentObj{OwnerId = i})
.ToList()}).ToList();
db.InsertAll (items);
Assert.AreEqual (parentCount, db.Table<TestObjWithOne2Many> ().Count ());
Assert.AreEqual (parentCount * childCount , db.Table<TestDependentObj> ().Count ());
return db;
}
示例8: SetUp
public void SetUp ()
{
db = new TestDb ();
db.Trace = true;
db.CreateTable<Product> ();
db.CreateTable<Order> ();
db.InsertAll (from i in Enumerable.Range (0, 22)
select new Product { Name = "Thing" + i, Price = (decimal)Math.Pow (2, i) });
changeCount = 0;
db.TableChanged += (sender, e) => {
if (e.Table.TableName == "Product") {
changeCount++;
}
};
}
示例9: CreateThem
public void CreateThem()
{
var db = new TestDb ();
db.CreateTable<Product> ();
db.CreateTable<Order> ();
db.CreateTable<OrderLine> ();
db.CreateTable<OrderHistory> ();
var orderLine = db.GetMapping(typeof(OrderLine));
Assert.AreEqual(6, orderLine.Columns.Length, "Order history has 3 columns");
var l = new OrderLine() {
Status = OrderLineStatus.Shipped
};
db.Insert(l);
var lo = db.Table<OrderLine>().Where(x => x.Status == CreateTableTest.OrderLineStatus.Shipped).FirstOrDefault();
Assert.AreEqual(lo.Id, l.Id);
}
示例10: CreateDb
SQLiteConnection CreateDb ()
{
var db = new TestDb ();
db.CreateTable<TestTable> ();
var items = from i in Enumerable.Range (0, Count)
select new TestTable { Datum = 1000+i };
db.InsertAll (items);
Assert.AreEqual (Count, db.Table<TestTable> ().Count ());
return db;
}
示例11: 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");
}
}
示例12: SetUp
public void SetUp ()
{
db = new TestDb ();
db.CreateTable<Product> ();
var prods = new[] {
new Product { Name = "Foo" },
new Product { Name = "Bar" },
new Product { Name = "Foobar" },
};
db.InsertAll (prods);
}
示例13: HasGoodNames
public void HasGoodNames()
{
var db = new TestDb ();
db.CreateTable<AFunnyTableName> ();
var mapping = db.GetMapping<AFunnyTableName> ();
Assert.AreEqual ("AGoodTableName", mapping.TableName);
Assert.AreEqual ("Id", mapping.Columns [0].Name);
Assert.AreEqual ("AGoodColumnName", mapping.Columns [1].Name);
}
示例14: InsertSucceeds
public void InsertSucceeds ()
{
var db = new TestDb ();
db.CreateTable<TestObj> ();
var o = new TestObj {
Text = "Hello",
IgnoredText = "World",
};
db.Insert (o);
Assert.AreEqual (1, o.Id);
}
示例15: ImplicitPK
public void ImplicitPK()
{
var db = new TestDb();
db.CreateTable<NoAttributes>(CreateFlags.ImplicitPK);
var mapping = db.GetMapping<NoAttributes>();
Assert.IsNotNull(mapping.PK);
Assert.AreEqual("Id", mapping.PK.Name);
Assert.IsTrue(mapping.PK.IsPK);
Assert.IsFalse(mapping.PK.IsAutoInc);
CheckPK(db);
}