本文整理汇总了C#中OrmLiteConnectionFactory.Save方法的典型用法代码示例。如果您正苦于以下问题:C# OrmLiteConnectionFactory.Save方法的具体用法?C# OrmLiteConnectionFactory.Save怎么用?C# OrmLiteConnectionFactory.Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OrmLiteConnectionFactory
的用法示例。
在下文中一共展示了OrmLiteConnectionFactory.Save方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: CascadesOnDelete
public void CascadesOnDelete()
{
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<TypeWithOnDeleteCascade>(true);
db.Save(new ReferencedType { Id = 1 });
db.Save(new TypeWithOnDeleteCascade { RefId = 1 });
Assert.AreEqual(1, db.Select<ReferencedType>().Count);
Assert.AreEqual(1, db.Select<TypeWithOnDeleteCascade>().Count);
db.Delete<ReferencedType>(r => r.Id == 1);
Assert.AreEqual(0, db.Select<ReferencedType>().Count);
Assert.AreEqual(0, db.Select<TypeWithOnDeleteCascade>().Count);
}
}
示例3: Can_Save_into_ModelWithFieldsOfDifferentTypes_table
public void Can_Save_into_ModelWithFieldsOfDifferentTypes_table()
{
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<ModelWithFieldsOfDifferentTypes>(true);
var row = ModelWithFieldsOfDifferentTypes.Create(1);
db.Save(row);
}
}
示例4: 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
示例5: CanInsertAndSelectByteArray
public void CanInsertAndSelectByteArray()
{
var orig = new TypeWithByteArrayField { Id = 1, Content = new byte[] { 0, 17, 0, 17, 0, 7 } };
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<TypeWithByteArrayField>(true);
db.Save(orig);
var target = db.SingleById<TypeWithByteArrayField>(orig.Id);
Assert.AreEqual(orig.Id, target.Id);
Assert.AreEqual(orig.Content, target.Content);
}
}
示例6: Can_Save_and_select_from_ModelWithFieldsOfDifferentTypes_table
public void Can_Save_and_select_from_ModelWithFieldsOfDifferentTypes_table()
{
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<ModelWithFieldsOfDifferentTypes>(true);
var row = ModelWithFieldsOfDifferentTypes.Create(1);
db.Save(row);
var rows = db.Select<ModelWithFieldsOfDifferentTypes>();
Assert.That(rows, Has.Count.EqualTo(1));
ModelWithFieldsOfDifferentTypes.AssertIsEqual(rows[0], row);
}
}
示例7: Can_Save_table_with_null_fields
public void Can_Save_table_with_null_fields()
{
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<ModelWithIdAndName>(true);
db.DeleteAll<ModelWithIdAndName>();
var row = ModelWithIdAndName.Create(0);
row.Name = null;
db.Save(row);
var rows = db.Select<ModelWithIdAndName>();
Assert.That(rows, Has.Count.EqualTo(1));
ModelWithIdAndName.AssertIsEqual(rows[0], row);
}
}
示例8: Can_Save_TaskQueue_table
public void Can_Save_TaskQueue_table()
{
using (var db = new OrmLiteConnectionFactory(ConnectionString, FirebirdDialect.Provider).Open())
{
db.CreateTable<TaskQueue>(true);
var row = TaskQueue.Create(1);
db.Save(row);
var rows = db.Select<TaskQueue>();
Assert.That(rows, Has.Count.EqualTo(1));
//Update the auto-increment id
row.Id = rows[0].Id;
TaskQueue.AssertIsEqual(rows[0], row);
}
}