0
有没有可能通过OrmLite插入新数据和更新现有记录?使用ServiceStack插入或替换sqlite或合并到SQL服务器OrmLite
有没有可能通过OrmLite插入新数据和更新现有记录?使用ServiceStack插入或替换sqlite或合并到SQL服务器OrmLite
目前还不清楚这个问题提出了什么,但是你可以插入或更新来自SQLite和SQL Server的数据。 OrmLite允许您使用POCO(普通旧CSharp对象)创建表和SELECT/INSERT数据,因此要将SQL Server数据导入到SQLite中,您只需从SQL Server数据库连接中选择行并将其插入到SQLite数据库连接中,例如:
var dbFactory = new OrmLiteConnectionFactory(
sqlServerConnString,
SqlServerDialect.Provider);
db.RegisterConnection("sqlite", "db.sqlite", SqliteDialect.Provider);
using (var dbSqlite = dbFactory.OpenDbConnection("sqlite"))
{
db.CreateIfNotExist<Poco>(); // Create tables in SQLite if needed
}
using (var db = dbFactory.OpenDbConnection())
{
var rows = db.Select<Poco>();
using (var dbSqlite = dbFactory.OpenDbConnection("sqlite"))
{
db.InsertAll(rows);
}
}
我在寻找这样的:'插入或更换INTO表(...)VALUES(...)' –
或'合并目标AS T使用源AS S ON .... WHEN NOT MATCHED BY目标......当匹配时......当源不匹配时; “非常感谢你。 –
@OmidMafakher否OrmLite不这样做。 OrmLite确实有'db.SaveAll()'它将插入或更新现有记录。 – mythz