在 C# 中,如何打开 SQLite 连接 in WAL mode ?
以下是我在正常模式下的打开方式:
SQLiteConnection connection = new SQLiteConnection("Data Source=" + file);
connection.Open();
// (Perform my query)
最佳答案
如何在 SQLiteConnection 连接字符串中指定工厂方法?
例如
public static class Connection
{
public abstract SQLiteConnection NewConnection(String file);
}
public class NormalConnection : Connection
{
public override SQLiteConnection NewConnection(String file)
{
return new SQLiteConnection("Data Source=" + file);
}
}
public class WALConnection : Connection
{
public override SQLiteConnection NewConnection(String file)
{
return new SQLiteConnection("Data Source=" + file + ";PRAGMA journal_mode=WAL;"
}
}
代码没有经过测试,希望大家能看懂,使用的时候就可以了。
SQLiteConnection conWal = new WALConnection(file);
conWAL.Open();
SQLiteConnection conNormal = new NormalConnection(file);
conNormal.Open();
关于c# - 如何以WAL方式打开SQLite连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15870104/