Tonights update to SisoDb

SisoDb is evolving and I just finished adding support for: Update, DeleteById and GetById.
For more information of what SisoDb is, read this post: SisoDb – An early prototype.

Update, DeleteById and GetById

Instead of writing about it i thought I would share some code:

var customer = new Customer
{
    Firstname = "Daniel",
    Lastname = "Wertheim",
    ShoppingIndex = ShoppingIndexes.Level1,
    CustomerSince = DateTime.Now,
    BillingAddress =
    {
        Street = "The billing street",
        Zip = "12345",
        City = "The billing city",
        Country = "Sweden",
        AreaCode = 345
    }
};

using (var unitOfWork = db.CreateUnitOfWork())
{
    unitOfWork.Insert(customer);
    unitOfWork.Commit();
}

using (var unitOfWork = db.CreateUnitOfWork())
{
    customer = unitOfWork.GetById<Customer>(customer.Id);
}

customer.DeliveryAddress = new Address
{
	Street = "The delivery street",
	Zip = "44453",
	City = "Gothenbourg",
	Country = "Sweden"
};

using (var unitOfWork = db.CreateUnitOfWork())
{
    unitOfWork.Update(customer);
    unitOfWork.Commit();
}

Concurrency support?

I’m thinking of adding concurrency support where I then plan to build it like this: If your entity contains a property “ConcurrencyToken : Guid” exceptions will be thrown when updates are performed on an outdated entity.
Opinions?

As always, the code and binaries are availible at the project site: http://code.google.com/p/sisodb

//Daniel

Writing my own NoSql DB?

Yesterday I got a thought:

why not write something very simple that can store object-graphs without mappings and other fuss.

Yes I know there’s MongoDb, RavenDb and several others, but it’s always a great deal of fun to write something of your own. So, inspired by Ayende’s technology choices, I spent a few hours last night just fiddling around with Lucene.Net and Json.Net. The result:

A simple model

public class Address
{
    public string Street { get; set; }
    public string Zip { get; set; }
    public string City { get; set; }
    public string Country { get; set; }
}

public class Customer
{
    [Key]
    public Guid? Id { get; set; }

    [Index]
    public string Firstname { get; set; }

    [Index]
    public string Lastname { get; set; }
        
    [Index]
    public int ShoppingIndex { get; set; }

    public Address BillingAddress { get; private set; }
    public Address DeliveryAddress { get; private set; }

    public Customer()
    {
        BillingAddress = new Address();
        DeliveryAddress = new Address();
    }
}

Consuming a Storage-provider

var customer = new Customer
                    {
                        Id = Guid.NewGuid(),
                        Firstname = "Daniel",
                        Lastname = "Wertheim",
                        ShoppingIndex = 99
                    };
customer.DeliveryAddress.Country = "Sweden";

var store = new LuceneStructureStore();
store.Insert(customer);

var refetched = store.GetByKey<Customer>(customer.Id.ToString());
...
...

Maybe it will grow to something useful. In the meantime I will continue my work with my MongoDB-provider, Simple-MongoDB.

//Daniel