Generic file-based database framework written in .NET Standard 2.0.
The Open Database Framework is a free and open source database library based on object serialization to file.
OpendDBF is a child project of ReflectXMLDB.
The project was written with .NET Standard 2.0,
which is compatible with .NET Core 2.0+, .NET Framework 4.6.1+ and .NET 5.0+.
OpenDBF is cross platform and can run in any OS that supports .NET Core 2.0 or higher.
More to come!
Download OpenDBF from nuget.
OpenDBF offers the traditional Get, Insert, Remove and Update methods commonly found in other database frameworks.
It creates a single file for all database objects and also supports zip compression with the use of Pack/Unpack methods.
There are two steps to get OpenDBF running:
Example:
[Serializable]
public class Sample : ICollectableObject
{
public string GUID { get; set; }
public uint EID { get; set; }
public string SomeData { get; set; }
}
Example:
//Initializes the database framework.
var dh = FrameworkFactory.GetFramework(FrameworkFactory.Framework_e.JSON);
//Creates the workspace.
string workspace = Path.Combine(Directory.GetCurrentDirectory(), @"DBSample");
dh.SetWorkspace(workspace);
//Creates a list of objects to be inserted.
//Sample inherits from ICollectableObject and is in the same namespace of SampleDatabase
List<Sample> samples = new List<Sample>();
for (int i = 0; i < 10; i++)
{
samples.Add(new Sample() { SomeData = string.Format("Data{0}", i) });
}
//Inserts the items in the database.
dh.Insert(samples);
//Gets all samples in the database.
var queryAllSamples = dh.Get<Sample>();
//Gets all samples that have Data5 as the value of the SomeData property.
var querySomeSamples = dh.Get<Sample>(x => x.SomeData == "Data5");
//Removes some of the items in the database.
dh.Remove<Sample>(querySomeSamples);
//Saves the database to a file
dh.Commit();
//Exports the database to a .db file.
dh.Pack(Path.Combine(Directory.GetCurrentDirectory(), @"Place"), "copyOfSampleDatabase1");
//Removes all "samples" from the database
dh.DropTable<Sample>();
//Clears internal resources.
dh.Dispose();
Happy coding!
Licensed under MIT License.