Unofficial .Net Binding for EJDB
Note: This is early days, API is subject to change.
- install-package Nejdb.Unofficial
What's differences with official binding
- tcejdbdll.dll is embedded in resource, and loaded at runtime for both x32/x64.
- API is closer to .Net style, not C style.
- Better unmanaged resource handling.
- Dropped support for Mono (I hope it's not hard to restore it).
- Nuget package available.
One snippet intro. Look at documentation for details.
using System;
using System.IO;
using Nejdb;
using Nejdb.Bson;
using Nejdb.Internals;
namespace sample
{
class MainClass
{
using (var library = Library.Create())
using (var database = library.CreateDatabase())
{
database.Open("MyDB.db");
using (var collection = database.CreateCollection("Parrots", CollectionOptions.None))
{
var parrot = BsonDocument.ValueOf(new
{
name = "Grenny",
type = "African Grey",
male = true,
age = 1,
birthdate = DateTime.Now,
likes = new[] { "green color", "night", "toys" },
extra = BsonNull.VALUE
});
collection.Save(parrot, false);
}
}
}
}
}