Accessing RavenDB from Silverlight

time to read 2 min | 332 words

The next build of RavenDB is going to include a major new feature, a Silverlight API. That comes in addition to our REST, .NET and JavaScript API.

What is means is that you can now just download RavenDB’s (the new bits are in the unstable fork right now) and start using it from Silverlight. Here is an example of how the code looks like:

var documentStore = new DocumentStore { Url = "http://localhost:8080" };

var entity = new Company { Name = "Async Company #1", Id = "companies/1" };
using (var session = documentStore.OpenAsyncSession(dbname))
    session.SaveChangesAsync(); // returns a task that completes asynchronously

     var query = session.Query<Company>()
       .Where(x => x.Name == "Async Company #1")
       .ToListAsync();  // returns a task that will execute the query

In order to handle the Silverlight Asynchronous requirement, we have taken dependency on the Async CTP, which brings us support for TPL on Silverlight.

Overall, this make things a lot simpler all around, I think.