本文整理汇总了C#中OrmLiteConnectionFactory.CreateTable方法的典型用法代码示例。如果您正苦于以下问题:C# OrmLiteConnectionFactory.CreateTable方法的具体用法?C# OrmLiteConnectionFactory.CreateTable怎么用?C# OrmLiteConnectionFactory.CreateTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OrmLiteConnectionFactory
的用法示例。
在下文中一共展示了OrmLiteConnectionFactory.CreateTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Transaction_rollsback_transactions_to_different_tables
public void Transaction_rollsback_transactions_to_different_tables()
{
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<ModelWithIdAndName>(true);
db.CreateTable<ModelWithFieldsOfDifferentTypes>(true);
db.CreateTable<ModelWithOnlyStringFields>(true);
db.DeleteAll<ModelWithIdAndName>();
db.Insert(new ModelWithIdAndName(0));
using (var dbTrans = db.BeginTransaction())
{
db.Insert(new ModelWithIdAndName(0));
db.Insert(ModelWithFieldsOfDifferentTypes.Create(3));
db.Insert(ModelWithOnlyStringFields.Create("id3"));
Assert.That(db.Select<ModelWithIdAndName>(), Has.Count.EqualTo(2));
Assert.That(db.Select<ModelWithFieldsOfDifferentTypes>(), Has.Count.EqualTo(1));
Assert.That(db.Select<ModelWithOnlyStringFields>(), Has.Count.EqualTo(1));
}
Assert.That(db.Select<ModelWithIdAndName>(), Has.Count.EqualTo(1));
Assert.That(db.Select<ModelWithFieldsOfDifferentTypes>(), Has.Count.EqualTo(0));
Assert.That(db.Select<ModelWithOnlyStringFields>(), Has.Count.EqualTo(0));
}
}
示例2: Can_create_ModelWithFieldsOfDifferentTypes_table
public void Can_create_ModelWithFieldsOfDifferentTypes_table()
{
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<ModelWithFieldsOfDifferentTypes>(true);
}
}
示例3: Can_preserve_ModelWithIdOnly_table
public void Can_preserve_ModelWithIdOnly_table()
{
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<ModelWithIdOnly>(true);
db.Insert(new ModelWithIdOnly(1));
db.Insert(new ModelWithIdOnly(2));
db.CreateTable<ModelWithIdOnly>(false);
var rows = db.Select<ModelWithIdOnly>();
Assert.That(rows, Has.Count.EqualTo(2));
}
}
示例4: Setup
public void Setup()
{
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<ReferencedType>(true);
}
}
示例5: Can_get_data_from_TableWithNamigStrategy_with_query_by_example
public void Can_get_data_from_TableWithNamigStrategy_with_query_by_example()
{
OrmLite.OrmLiteConfig.DialectProvider.NamingStrategy =
OrmLite.OrmLiteConfig.DialectProvider.NamingStrategy = new PrefixNamingStrategy
{
TablePrefix = "tab_",
ColumnPrefix = "col_",
};
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<ModelWithOnlyStringFields>(true);
ModelWithOnlyStringFields m = new ModelWithOnlyStringFields()
{
Id = "998",
AlbumId = "112",
AlbumName = "ElectroShip",
Name = "QueryByExample"
};
db.Save<ModelWithOnlyStringFields>(m);
var modelFromDb = db.Where<ModelWithOnlyStringFields>(new {Name = "QueryByExample"})[0];
Assert.AreEqual(m.Name, modelFromDb.Name);
}
OrmLite.OrmLiteConfig.DialectProvider.NamingStrategy = new OrmLiteNamingStrategyBase();
}
示例6: CanCreateSimpleForeignKey
public void CanCreateSimpleForeignKey()
{
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<TypeWithSimpleForeignKey>(true);
}
}
示例7: CanCreateForeignWithOnDeleteNoAction
public void CanCreateForeignWithOnDeleteNoAction()
{
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<TypeWithOnDeleteNoAction>(true);
}
}
示例8: Can_create_ModelWithIdOnly_table
public void Can_create_ModelWithIdOnly_table()
{
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<ModelWithIdOnly>(true);
}
}
示例9: Can_create_TableWithNamigStrategy_table_nameUnderscoreCoumpound
public void Can_create_TableWithNamigStrategy_table_nameUnderscoreCoumpound()
{
using (new TemporaryNamingStrategy(new UnderscoreSeparatedCompoundNamingStrategy()))
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<ModelWithOnlyStringFields>(true);
}
}
开发者ID:ServiceStack,项目名称:ServiceStack.OrmLite,代码行数:8,代码来源:OrmLiteCreateTableWithNamigStrategyTests.cs
示例10: Can_insert_into_ModelWithFieldsOfDifferentTypes_table
public void Can_insert_into_ModelWithFieldsOfDifferentTypes_table()
{
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<ModelWithFieldsOfDifferentTypes>(true);
var row = ModelWithFieldsOfDifferentTypes.Create(1);
db.Insert(row);
}
}
示例11: Can_create_ModelWithCompositeIndexFields_table
public void Can_create_ModelWithCompositeIndexFields_table()
{
OrmLiteConfig.DialectProvider.DefaultStringLength=128;
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<ModelWithCompositeIndexFields>(true);
var sql = OrmLiteConfig.DialectProvider.ToCreateIndexStatements(typeof(ModelWithCompositeIndexFields)).Join();
Assert.IsTrue(sql.Contains("idx_modelwcif_name"));
Assert.IsTrue(sql.Contains("idx_modelwcif_comp1_comp2"));
}
}
示例12: Can_get_data_from_TableWithNamigStrategy_with_GetById
public void Can_get_data_from_TableWithNamigStrategy_with_GetById()
{
using (new TemporaryNamingStrategy(new PrefixNamingStrategy { TablePrefix = "tab_", ColumnPrefix = "col_" }))
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<ModelWithOnlyStringFields>(true);
ModelWithOnlyStringFields m = new ModelWithOnlyStringFields() { Id= "999", AlbumId = "112", AlbumName="ElectroShip", Name = "MyNameIsBatman"};
db.Save<ModelWithOnlyStringFields>(m);
var modelFromDb = db.SingleById<ModelWithOnlyStringFields>("999");
Assert.AreEqual(m.Name, modelFromDb.Name);
}
}
开发者ID:ServiceStack,项目名称:ServiceStack.OrmLite,代码行数:14,代码来源:OrmLiteCreateTableWithNamigStrategyTests.cs
示例13: Can_insert_and_select_from_OrderLineData
public void Can_insert_and_select_from_OrderLineData()
{
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<SampleOrderLine>(true);
var orderIds = new[] { 1, 2, 3, 4, 5 }.ToList();
orderIds.ForEach(x => db.Insert(
SampleOrderLine.Create(Guid.NewGuid(), x, 1)));
var rows = db.Select<SampleOrderLine>();
Assert.That(rows, Has.Count.EqualTo(orderIds.Count));
}
}
示例14: Can_GetById_string_from_ModelWithOnlyStringFields_table
public void Can_GetById_string_from_ModelWithOnlyStringFields_table()
{
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<ModelWithOnlyStringFields>(true);
var rowIds = new List<string>(new[] {"id-1", "id-2", "id-3"});
rowIds.ForEach(x => db.Insert(ModelWithOnlyStringFields.Create(x)));
var row = db.GetById<ModelWithOnlyStringFields>("id-1");
Assert.That(row.Id, Is.EqualTo("id-1"));
}
}
示例15: Can_GetById_int_from_ModelWithFieldsOfDifferentTypes_table
public void Can_GetById_int_from_ModelWithFieldsOfDifferentTypes_table()
{
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<ModelWithFieldsOfDifferentTypes>(true);
var rowIds = new List<int>(new[] {1, 2, 3});
rowIds.ForEach(x => db.Insert(ModelWithFieldsOfDifferentTypes.Create(x)));
var row = db.GetById<ModelWithFieldsOfDifferentTypes>(1);
Assert.That(row.Id, Is.EqualTo(1));
}
}