我在 SQLite 上使用带有 NHibernate 的 C#。 System.Data.SQLite 版本 1.0.88 SQLite 版本 3.7.17
我最近发现了 SQLite WAL mode它看起来正是我需要的。 问题是我似乎无法让它工作。
文档简单地说明:
To convert to WAL mode, use the following pragma:
PRAGMA journal_mode=WAL;
The journal_mode pragma returns a string which is the new journal mode. On success, the pragma will return the string "wal". If the conversion to WAL could not be completed (for example, if the VFS does not support the necessary shared-memory primitives) then the journaling mode will be unchanged and the string returned from the primitive will be the prior journaling mode (for example "delete").
我已经在代码中尝试了这两个:
ISQLQuery query = session.CreateSQLQuery("PRAGMA journal_mode=WAL;");
object result = query.UniqueResult();
并在SQLiteman内管理应用。
在每种情况下,我都会得到“删除”的返回值。即数据库未能进入 WAL 模式。 问题是,我不知道为什么。我在文档中看到的唯一可能是您的文件系统不支持共享内存原语,但我使用的是 Win 7,所以这不是问题。
关于如何启用 WAL 模式或弄清楚它为何不起作用的任何想法?
最佳答案
尝试在连接构建器上设置编译指示。
SQLiteConnectionStringBuilder connBuilder = new SQLiteConnectionStringBuilder();
connBuilder.JournalMode = SQLiteJournalModeEnum.Wal;
关于c# - 不能使用 SQLite WAL 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19111064/