BryantBrothers.ProtoDB (v0.2.5 BETA)

@ashesid

Description:

Rapidly prototype applications without having to worry about database creation and setup. Create simple POCO classes and save them to the database. Simple and quick for small database sizes, swap out for a more convientional database once you scale.

Release Notes:

v0.2.5 - Added Query<> method and GetAll<> methods. Fixed SQL generation in ProtoServer.GenerateSql() and added primary key support.

v0.2.4 - Initial beta release. Sorting out Nuget package and dependancies. Supports basic data types in POCO classes but many features still to implement.

Example usage:

// Add using to your class
using BryantBrothers.ProtoDB;

// Get or create a new DB called "test"
var db = ProtoServer.GetDB("test");

// Create an instance of a Person and save it to "test" DB
var person = new Person
{
	Id = 1,
	FirstName = "Ashley",
	LastName = "Bryant"
};

db.Save(person);

// Test retrieving the person with ID = 1.
var retrievedPerson = db.Get("1");

// Retrieve all people in Person table
var allPeople = db.GetAll();

// Or query the Person table using LINQ
var queryResults = db.Query().Where(p => p.LastName == "Bryant");
		

Notes:

Objects are saved by the value of a field called "Id" by convention. If no "Id" field exists then decorate the Id field with the [ProtoDB_ID] attribute.

Decorate your objects with [ProtoDB_Table] to mark them as ProtoDB tables.

Once your domain objects have settled down you can shift to a more conventional database (e.g. SQL Server) by calling the GenerateSql() method.

// Generate a list of strings which are SQL statements
var sql = ProtoServer.GenerateSql();
	

The data is stored under "App_Data" folder as JSON files. Data is loaded in memory so is quick for retrival, slower for loading and insert/updates. It shouldn't matter for small data sizes (which is mainly what you have when prototyping an app) but it won't scale at all for larger datasets (shift to a proper database).