public
Created

Load data from XML to in-memory SQLite instance

  • Download Gist
gistfile1.cs
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
SQLiteConnection connection = boundSession.GetConnection();
 
using (var cmd = new SQLiteCommand("PRAGMA foreign_keys = OFF", connection))
{
cmd.ExecuteNonQuery();
}
 
var sqlLiteUnitTest = new SqlLiteDbUnitTest(connection);
 
sqlLiteUnitTest.ReadXmlSchema(xsdFile);
sqlLiteUnitTest.ReadXml(xmlDataFile);
sqlLiteUnitTest.PerformDbOperation(DbOperationFlag.CleanInsertIdentity);
 
using (var cmd = new SQLiteCommand("PRAGMA foreign_keys = ON", (SQLiteConnection)connection))
{
cmd.ExecuteNonQuery();
}
 
// In-memory SQLite instances are created per connection. Use same connection at unittest

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.