SisoDb – Some code preview

I thought I would share some code of how my SisoDb (Simple-Structure-Oriented-Db) looks like.

As of right now you have to provide info about which member contains the key. This will change and will instead be convention based.

var schemaBuilder = new ManualSchemaBuilder();
schemaBuilder.Register<Customer>(builder => builder.SetKey(c => c.Id));

You can also use SchemaBuilder.AddIndex to provide specific indexes that you wan’t to query more efficiently.

var schemaBuilder = new ManualSchemaBuilder();
    builder => builder
        .SetKey(c => c.Id)
        .AddIndex(c => c.Lastname));

The next step is to create a database. Supported options are I/O-based or a Virtual (in-memory) database. The virtual only lasts as long as the UnitOfWork lives. The database is designed to be long-lived and is something you would keep alive, preferable using your IoC-container.

var connectionInfo = new LuceneConnectionInfo(LuceneDbTypes.Io, @"C:\#Temp\SisoDb\ConsoleSample");
var database = new LuceneDatabase(connectionInfo);

var schemas = schemaBuilder.GetSchemas();

Now we are ready to add some data, so lets create a Customer and add it using UnitOfWork

var customer = new Customer
                        Firstname = "Daniel",
                        Lastname = "Wertheim",
                        ShoppingIndex = ShoppingIndexes.Level1,
                        CustomerSince = DateTime.Now

using (var unitOfWork = database.CreateUnitOfWork())

That’s it. If Commit() isn’t called everything is rolled back.

I will soon publish the source code on Google Code.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s