This project is read-only.
Project Description
What CouchDB is for documents that is The Lounge Repository for Domain Driven Design (DDD) entities: a tool to make persistence easier, much easier than it´s today.

The Lounge Repository strives to be a generic repository working embedded or remote.

This is a work in progress project.

Samples of what you can do

The Lounge Repository lets you store any object in a file.

using LoungeRepo.Contracts.Core;  // reference assembly LoungeRepo.Contracts
using LoungeRepo.Core;  // reference like named assembly

class Person
    public string Name;
using(var repo = LoungeRepository())
    var p = new Person{Name="Peter", ...};

    repo.Store(p, "1234");

You don´t need to make the class serializable. But you need to identify an object you store with at least an id ("1234" in the example). In addition you can cluster objects in partitions you name to your liking, e.g.

repo.Store(p, "1234", "contacts");

Objects stored like this are called an entity, i.e. an object with an identity (consisting of its id plus the partition).

Entities can be loaded by providing their identity:

p = repo.Load<Person>("1234", "contacts");

Load() and Store() of course work on the whole object graph. So if an object references others they too are loaded/stored. This even works for cyclic references.

To delete an entity just use its identity again:

repo.Delete("1234", "contacts");

If you want to query entities you need to provide the root type and then can use Linq:

var selected = repo.GetExtent<Person>().Where(p => p.Name.StartsWith("Pet"));
foreach(Person p in selected)

Currently, though, only entities loaded or stored during a session are accessible through an extent. Entities stored previously but not yet accessed are not transparently loaded for the query. Not yet at least ;-) But you can prefetch all entities in a repository like this:

using LoungeRepo.Core.Extensions; // reference like named assembly

using(var repo =...)

Any object can be stored as an entity. But most likely you´ll want to designate some classes in your application to be "true entities" in the DDD sense. This you can do by letting them implement the interface ILoungeRepoEntityIdentity:

class PersonEntity : ILoungeRepoEntityIdentity
    public string Id {get; set;}
    public string Partition {get; set;}

    public string Name;
var pe = new PersonEntity { Id="9876", Partition="contacts", Name="Mary", ...};

Instead of implementing the interface you can just define a string property with name Id.

How an entity gets its id and partition assigned is not the concern of the Lounge Repository. Do it any way you like. The repo just needs to be able to access them through the interface (in a read-only manner).

Each entity is stored in its own file! That means if you store some entity which directly or indirectly references other entities the Lounge Repository will detect this and store all the entities in separate files. This means on the other hand you can load any of these entities on its own!

This is contrary to what CouchDB or StupidDB do. They are document oriented and store data as is. The Lounge Repository on the other hand is not document oriented but entity oriented. It´s thus more fit to be used in business applications which usually handle object graphs consisting of several entities.

If you have any feedback, please feel free to post it in the discussion and issue section here at codeplex.

Enjoy the Lounge Repository!

-Ralf Westphal,

Last edited Apr 19, 2010 at 10:52 PM by ralfw, version 9