The thread-safe/object oriented/relational/fast/xml-based database engine
XOD database -pronounced as “ZOD”- is a thread-safe object oriented relational database for .NET and JAVA developers (JAVA version is still half cooked). XOD uses embedded XML files for storage, that means the data will be readable even without the application the database created for, and it is also better for integration and simple for data migration. Even If you didn’t like your database being readable like text files, you can always secure XOD files with encryption.
Based on the development approach, developers might start designing the application model classes, design the actual database storage and then build a data mapping layer between the two. They might go back and forth between these two design layers whenever new update comes up. But what if you can skip the second, and third layers, and just work on the model classes layer only, not warring about the database design and mapping objects to database records, because XOD will take it from there; that would be great, right! Even if your application is big that one XOD database might not be sufficient for, you can use unlimited number XOD databases, even for supportive tasks like configuration data storage. You can also use XOD at the development stages only, until you feel satisfied about your application model classes and business logic, then push your verified models design and build the actual database.
This little documentation gives you brief guide lines for how to utilize XOD for .NET developers.
- Support all CRUD Operations: Create, Read, Update and Delete
- Supported data types:
- Primitive data types
- Value type properties like struct and enum
- String and DateTime objects are treated as value types as well
- Reference type objects
- Complex types (explained in [ForeignKey] Attribute and Complex Types sections)
- Anonymous reference types … awesome! (explained in Anonymous (Dynamic) Types section)
- One dimensional arrays of any of the above types
- One dimensional generic collection of any of the above types (e.g. List, List)
- Queries
- Self-join
- Triggers
- 1-1, 1-Shared, 1-M, and M-M Relationships
- Cascade Update/Delete
- Password/encryption security options
- Primary Keys, Composite Keys
- Unique-Value and Required validation rules
- Autonumber/Autogenerate values
- Encrypted properties
- Special-character string properties (useful for HTML contents)
- Excludable properties
- Eager/Lazy data loading options
- Thread-safe
- Caching
You can download Xod library from dist folder in this repository or add it directly to your application as NuGet package, to do this:
-
Open Visual Studio IDE
-
Create a new console application
-
In Package Manager Console type the following:
install-package Xod -pre
Now, let's try some code:
-
In Program.cs add
using Xod;
namespace -
Create a new class
ToDo
with the following properties
public class ToDo
{
public int Id { get; set; }
public string Title { get; set; }
public bool Done { get; set; }
}
- Add this code to
Main()
method:
XodContext db = new XodContext(@"c:\xod\data.xod");
db.Insert(new ToDo() { Title = "Read a book" });
When running the application, a new Xod database will be created unless it was already exist, then a new object of ToDo class will be inserted into the database.
- Go to the database path (in our exampe c:\xod) and check out the database contents in xml-format files.
using System;
using System.Collections.Generic;
using System.Linq;
using Xod;
namespace XodConsoleApplication
{
class Program
{
static void Main(string[] args)
{
XodContext db = new XodContext(@"c:\xod\data.xod");
//insert new object
db.Insert(new ToDo() { Title = "Read a book..." });
//read the new inserted object
var tdi = db.Find<ToDo>(s => s.Id == 1);
//update the object
tdi.Done = true;
db.Update(tdi);
Console.WriteLine("Xod operations completed!");
Console.ReadKey();
}
}
public class ToDo
{
public int Id { get; set; }
public string Title { get; set; }
public bool Done { get; set; }
}
}