Skip to content

hendryten/ejdb-csharp

 
 

Repository files navigation

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);
				}
			}
		}
	}
}

About

Unofficial EJDB C# .Net binding

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 99.6%
  • PowerShell 0.4%