What about the factory approach for specifying SQLiteConnection in the connection string?
eg,
public static class Connection { public abstract SQLiteConnection NewConnection(String file); } public class NormalConnection : Connection { public override SQLiteConnection NewConnection(String file) { return new SQLLiteConneciton("Data Source=" + file); } } public class WALConnection : Connection { public override SQLiteConnection NewConnection(String file) { return new SQLLiteConnection("Data Source=" + file + ";PRAGMA journal_mode=WAL;" } }
The code is untested, but I hope you can get this idea, so when you use it, you can do it.
SQLLiteConnection conWal = new WALConnection(file); conWAL.Open(); SQLLiteConnection conNormal = new NormalConnection(file); conNormal.Open();
source share