本文整理汇总了C#中SQLite.Net.Tests.TestDb.CreateTable方法的典型用法代码示例。如果您正苦于以下问题:C# TestDb.CreateTable方法的具体用法?C# TestDb.CreateTable怎么用?C# TestDb.CreateTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLite.Net.Tests.TestDb
的用法示例。
在下文中一共展示了TestDb.CreateTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDb
private SQLiteConnection CreateDb()
{
var db = new TestDb();
db.CreateTable<TestTable>();
db.CreateTable<TestTableCompositeKey>();
var items =
from i in Enumerable.Range(0, Count)
select new TestTable
{
Datum = 1000 + i,
Test = "Hello World"
}
;
db.InsertAll(items);
var itemsCompositeKey =
from i in Enumerable.Range(0, Count)
select new TestTableCompositeKey
{
Datum = 1000 + i,
Test = "Hello World",
Id = i,
TestIndex = i + 1
}
;
db.InsertAll(itemsCompositeKey);
Assert.AreEqual(Count, db.Table<TestTableCompositeKey>().Count());
return db;
}
示例2: CreateDb
private TestDb CreateDb()
{
var db = new TestDb();
db.CreateTable<Product>();
db.CreateTable<Order>();
db.CreateTable<OrderLine>();
db.CreateTable<OrderHistory>();
return db;
}
示例3: CreateThem
public void CreateThem()
{
var db = new TestDb();
db.CreateTable<Product>();
db.CreateTable<Order>();
db.CreateTable<OrderLine>();
db.CreateTable<OrderHistory>();
VerifyCreations(db);
}
示例4: 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);
}
示例5: 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,
}
});
}
示例6: UpperAndLowerColumnNames
public void UpperAndLowerColumnNames()
{
using (var db = new TestDb(true)
{
TraceListener = DebugTraceListener.Instance
})
{
db.CreateTable<LowerId>();
db.CreateTable<UpperId>();
List<SQLiteConnection.ColumnInfo> cols = db.GetTableInfo("Test").ToList();
Assert.That(cols.Count, Is.EqualTo(1));
Assert.That(cols[0].Name, Is.EqualTo("Id"));
}
}
示例7: TestColumnValues
public void TestColumnValues()
{
using (TestDb db = new TestDb())
{
db.CreateTable<WithDefaultValue>();
string failed = string.Empty;
foreach (var col in db.GetMapping<WithDefaultValue>().Columns)
{
if (col.PropertyName == "TestInt" && !col.DefaultValue.Equals(WithDefaultValue.IntVal))
failed += " , TestInt does not equal " + WithDefaultValue.IntVal;
if (col.PropertyName == "TestDecimal" && !col.DefaultValue.Equals(WithDefaultValue.DecimalVal))
failed += "TestDecimal does not equal " + WithDefaultValue.DecimalVal;
if (col.PropertyName == "TestDateTime" && !col.DefaultValue.Equals(WithDefaultValue.DateTimegVal))
failed += "TestDateTime does not equal " + WithDefaultValue.DateTimegVal;
if (col.PropertyName == "TestString" && !col.DefaultValue.Equals(WithDefaultValue.StringVal))
failed += "TestString does not equal " + WithDefaultValue.StringVal;
}
Assert.True(string.IsNullOrWhiteSpace(failed), failed);
}
}
示例8: ImplicitIndex
public void ImplicitIndex()
{
var db = new TestDb();
db.CreateTable<NoAttributes>(CreateFlags.ImplicitIndex);
TableMapping mapping = db.GetMapping<NoAttributes>();
TableMapping.Column column = mapping.Columns[2];
Assert.AreEqual("IndexedId", column.Name);
Assert.IsTrue(column.Indices.Any());
}
示例9: CreateDb
private SQLiteConnection CreateDb()
{
var db = new TestDb();
db.CreateTable<TestTable>();
IEnumerable<TestTable> items = from i in Enumerable.Range(0, Count)
select new TestTable
{
Two = 2
};
db.InsertAll(items);
Assert.AreEqual(Count, db.Table<TestTable>().Count());
return db;
}
示例10: CreateUniqueIndexes
public void CreateUniqueIndexes()
{
using (var db = new TestDb())
{
db.CreateTable<TheOne>();
List<IndexInfo> 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");
}
}
示例11: ImplicitAutoIncAsPassedInTypes
public void ImplicitAutoIncAsPassedInTypes()
{
var db = new TestDb();
db.CreateTable(typeof (PkAttribute), CreateFlags.AutoIncPK);
TableMapping mapping = db.GetMapping<PkAttribute>();
Assert.IsNotNull(mapping.PK);
Assert.AreEqual("Id", mapping.PK.Name);
Assert.IsTrue(mapping.PK.IsPK);
Assert.IsTrue(mapping.PK.IsAutoInc);
}
示例12: HasGoodNames
public void HasGoodNames()
{
var db = new TestDb();
db.CreateTable<AFunnyTableName>();
TableMapping mapping = db.GetMapping<AFunnyTableName>();
Assert.AreEqual("AGoodTableName", mapping.TableName);
Assert.AreEqual("Id", mapping.Columns[0].Name);
Assert.AreEqual("AGoodColumnName", mapping.Columns[1].Name);
}
示例13: ImplicitAutoInc
public void ImplicitAutoInc()
{
var db = new TestDb();
db.CreateTable<PkAttribute>(CreateFlags.AutoIncPK);
TableMapping mapping = db.GetMapping<PkAttribute>();
Assert.IsFalse(mapping.HasCompositePK);
Assert.IsNotNull(mapping.PK);
Assert.AreEqual("Id", mapping.PK.Name);
Assert.IsTrue(mapping.PK.IsPK);
Assert.IsTrue(mapping.PK.IsAutoInc);
}
示例14: CanUseSubtypeOfTableAttribute
public void CanUseSubtypeOfTableAttribute()
{
var db = new TestDb();
db.CreateTable<Cat>();
db.Insert(new Cat()
{
Breed = "Siamese"
});
int numCats = db.ExecuteScalar<int>("select count(*) from Cats");
Assert.That(numCats,Is.EqualTo(1), "The resulting num cats should be 1.");
}
示例15: ToUpper
public void ToUpper()
{
var db = new TestDb();
db.CreateTable<TestTable>();
var testTable = new TestTable()
{
Name = "test"
};
db.Insert(testTable);
var x = db.Table<TestTable>().Where(t => t.Name.ToUpper() == "TEST");
Assert.AreEqual(1, x.Count());
}