More
Moving from XOD 1.x
XOD 2 keeps the 1.x API and attributes, opens 1.x databases, and adds new features you can use when you need them.
XOD 2 is a rework of the 2017 library (Xod 0.1.x and Xod.Core), built for .NET 8 and .NET 9.
Code written for 1.x compiles against XOD 2 with few or no changes, and XOD 2 opens 1.x databases. The 1.x
code is on the legacy branch.
Upgrading
-
Move the project to .NET 8 or .NET 9.
-
Replace the
Xod0.1.x orXod.Corereference with the currentXodpackage:dotnet add package Xod -
Back up the database folder, then open it as before:
using Xod; using var db = new XodContext(@"c:\xod\data.xod"); var item = db.Find<ToDo>(s => s.Id == 1); item.Done = true; db.Update(item); -
Run your tests against a copy of the real data before switching production over.
What stays the same
- The namespace (
Xod) and the entry point (XodContext). Insert,Update,Delete,Find,FirstMatch,Query,Select,Count,Dropand the other 1.x methods.- The attributes:
[PrimaryKey],[UniqueKey],[ForeignKey],[Children],[ParentKey],[Property],[Crypto],[Markup],[Required],[NotMapped],[GenericTypeProperty]. - The XML file format.
What’s better
- Indexes. Lookups by key and by indexed property use B-tree indexes instead of scans.
- Unique keys are enforced on insert and on update.
- Transactions: a commit that a process crash cuts short is undone from its journal.
- Concurrency: many readers at once, with writes serialized one at a time inside one context.
[Children]and[ParentKey]are optional when names follow the convention.
What’s new
Insert<T>returns the typed object with its key filled in.- JSON and binary storage formats, and
XodMigratorto convert. See Storage. BeginTransaction(). See Transactions.- SQL
SELECTfrom .NET (db.Sql) and thexod queryCLI. See Reading data. - Async methods. See Reading data.
SHA256,SHA512and reversibleAES256property crypto. See Security.DateOnly,TimeOnly,DateTimeOffset, dictionaries with preserved string comparers, and records.
Things to check
- Cascade. Children collections cascade deletes: deleting a parent deletes its children and its plain lists of objects without a key. Check that this matches what your code expects (see Relationships).
MD5andSHA1hashes from 1.x. UseSHA256orSHA512for new data.CryptoHelper.VerifyHashand SQL’sVERIFY_HASHverify values against 1.x digests (decimal digits) as well as 2.x digests (hex), and updating a row preserves its stored 1.x digest. Open a 1.x database withDatabaseOptions.Legacy1xDigests = trueso 1.x digests also stay intact when written elsewhere (inserted into another database, copied to another row, or rewritten with a parent); leave it off if[Crypto]properties may store plain digit strings.- A bare
[Crypto]hashes withSHA256in XOD 2, where 1.x usedMD5. Specify[Crypto(CryptoMethod.MD5)]explicitly if you need new values hashed with MD5. - Encrypted 1.x databases. Encrypted 1.x databases open with their password. ASCII passwords open
directly; non-ASCII passwords open in the form 1.x hashed them (
?for non-ASCII characters; databases encrypted by pre-September-2016 1.x builds can’t be opened). Files keep 1.x’s unsalted key until you runChangePassword, so change the password after migrating. - Empty strings. Empty strings stored by 1.x read back as
""(see Values read back as written). - Already on XOD 2? See Upgrading for version-to-version changes within 2.x.
- Licence. XOD 2 is Apache-2.0. The 0.1.x line and the 1.0.0 betas stay under MIT.