Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Raven.DynamicSession is a dynamic session allowing you to use RavenDB without the need of POCOs.
Failed to load latest commit information.
src added more tests and fixed bugs raised by those tests


Raven.DynamicSession is a dynamic session allowing you to use RavenDB without the need of POCOs.

The idea came up discussing APIs with prabir in and so I decided to see if I could come up with something that achieved what he wanted.

So far I have a working prototype that allows for you to create a Dynamic Session which you can Insert or Load dynamic objects.

using (dynamic session = documentStore.OpenDynamicSession())
        Name = "Rabbit"
    }, "909");
        Name = "Banana"
    }, "123");
        FirstName = "Phillip"
    }, "1");
        FirstName = "Prabir"
    }, "2");


The above uses the dynamic property 'Posts' or 'people' as the document collection, then invokes a dynamic method which takes a parameter of data. In this case it takes 2 arguments, the object, and the Id. Currently I can't auto insert Ids but that may be possible in the future.

These objects are automatically inserted and it uses the property to set the Raven-Entity-Name to ensure they all end up in their own collections.

using (dynamic session = documentStore.OpenDynamicSession())
    dynamic post1 = session.Posts.load(123);

    dynamic post2 = session.Posts.Load(909);

    dynamic person1 = session.People.load(1);

    dynamic person2 = session.People.Load(2);

This code, like the previous code uses the property as the collection, and invokes the Load method from the normal RavenDB session, returning a dynamic type. At the moment it accepts an int for the Id and uses the property to construct the RavenDB document Id like: posts/123

I wouldn't recommend using this for any real world projects... yet, maybe in the future but this is very much a prototype project to see if it's even possible to achieve something like this.

Something went wrong with that request. Please try again.