2017-06-29 39 views

回答

1

目前还不清楚这个问题提出了什么,但是你可以插入或更新来自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); 
    } 
} 
+0

我在寻找这样的:'插入或更换INTO表(...)VALUES(...)' –

+0

或'合并目标AS T使用源AS S ON .... WHEN NOT MATCHED BY目标......当匹配时......当源不匹配时; “非常感谢你。 –

+0

@OmidMafakher否OrmLite不这样做。 OrmLite确实有'db.SaveAll()'它将插入或更新现有记录。 – mythz