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

One thought on “Tonights update to SisoDb

  1. Cool – I’ve been thinking about building something like this for a while.

    Nice work.

    Why not use Sqlserver timestamps for concurrency as these are fairly well understood and optimized.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s