Reference
DatabaseOptions
Every setting you can pass when opening a database, with its default.
Pass a DatabaseOptions as the third constructor argument. Anything you don’t set keeps its default.
var options = new DatabaseOptions
{
StorageFormat = StorageFormat.Json,
Durability = DurabilityMode.Buffered,
LockRetryTimeoutMs = 2000,
};
using var db = new XodContext("data/app.xodj", options: options);
| Option | Type | Default | What it does |
|---|---|---|---|
StorageFormat |
StorageFormat |
Xml |
Xml, Json or Binary. When set explicitly, overrides the format; left unset, an existing database writes in the format its database file records and a new one uses its extension. An undefined enum value throws ArgumentOutOfRangeException. See Choosing a format. |
Durability |
DurabilityMode |
Immediate |
Immediate writes each change to disk before the call returns; Buffered holds changes until Flush() or dispose. See Durability. |
InitialCreate |
bool |
true |
Create the database if the file doesn’t exist. With false, opening a missing database throws DatabaseFileException immediately without creating lock files. |
EnableIndexing |
bool |
true |
Maintain primary, unique and secondary indexes. |
PageSize |
int |
524288 (512 KB) |
Bytes of rows per page file. See Page size. |
LazyLoad |
bool |
false |
Don’t load relationships unless they’re named in include. |
LazyLoadParent |
bool |
true |
Don’t load a child’s parent reference unless it’s named in include. |
LockRetryTimeoutMs |
int |
0 |
How long an open waits while another context or process has the database open before throwing DatabaseLockedException. See Processes. |
TransactionTimeoutMs |
int |
30000 |
How long BeginTransaction() waits for another thread’s reads, writes or transaction, and how long another thread’s read or write waits for an open transaction, before throwing TransactionException. See Transactions. |
PropertyEncryptionKey |
string |
null |
A secret your application keeps that protects the database’s [Crypto(AES256)] key (never stored on disk). Opening a new database with it creates the key immediately. See Encrypting a property. |
SqlSchema |
SqlSchemaSource |
Classes |
Where SQL takes each table’s column types from. Classes: your classes, falling back to the recorded schema for tables whose class isn’t loaded. Recorded: always the recorded schema, as xod query does. |
Legacy1xDigests |
bool |
false |
For a database carrying XOD 1.x [Crypto] MD5/SHA1 digests. With it on, a 1.x digest read from this database stays a digest wherever it is written. Leave it off when [Crypto] values may be plain digit strings. See Moving from XOD 1.x. |
LockDatabase |
bool |
false |
Kept for source compatibility; has no effect because every context holds the database exclusively. |
EnableCompression |
bool |
false |
Obsolete (warning CS0618); has no effect. Use StorageFormat.Binary for compressed files. |
The password isn’t an option: pass it as the constructor’s second argument. See Passwords and encryption.