/ejdb-csharp

Unofficial EJDB C# .Net binding

Primary LanguageC#GNU Lesser General Public License v2.1LGPL-2.1

Unofficial .Net Binding for EJDB

Note: This is early days, API is subject to change.

You can install it using nuget:

  • install-package Nejdb.Unofficial

What's differences with official binding

  1. tcejdbdll.dll is embedded in resource, and loaded at runtime for both x32/x64.
  2. API is closer to .Net style, not C style.
  3. Better unmanaged resource handling.
  4. Dropped support for Mono (I hope it's not hard to restore it).
  5. 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);
				}
			}
		}
	}
}