Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:


+972 52-548-6969

, @ Q c

Posts: 6,128 | Comments: 45,550

filter by tags archive

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.


Ruben Bartelink

Curious whether you considered the Reactive stuff as a way to manage the asynchrony, i.e., generating Observables instead of Tasks, and having people have to reference a DLL or two from that.

Admittedly it's conceptually heavier and not a minimal solution to the problem, but it's more 'released' than the Async CTP.

Are you talking just taking the DLLs and running (and assuming they'll make it into SL5) or using the compiler too?

But then released is in the eye of the beholder when it's not all sitting in a public repo I guess.

Ayende Rahien


I think that Reactive is much more complicated than the TPL.

And yes, I am talking about just the TPL, you don't need the compiler.

Not following what you mean by not in a public repo?

Ruben Bartelink

Re public repo, I meant that the async CTP and the devlabs drops of RX are more or less equivalent in terms of usability for the world that doesnt want to get intimate with or take dependencies on release schedules:

a) whether they're final

b) whether one would expect to be able to see the source for <$35

c) whether one would expect to be able to send a patch

d) whether they can be expected to have a delivery mechanism that cant be broken by the release of ASP.NET MVC3

For others, the relevant DLL containing the TPL impl sits in <userprofiledir\Documents\Microsoft Visual Studio Async CTP\Samples after installation


Why isn't the API consistent with non-silverlight code ... I think it should be like this

var entity = new Company { Name = "Async Company #1", Id = "companies/1" };

using (var session = documentStore.OpenSessionAsync(dbname))



session.SaveChanges(); // returns a task that completes asynchronously

 var query = session.Query


   .Where(x => x.Name == "Async Company #1")

   .ToList();  // returns a task that will execute the query


Which might be used also in non-silverlight environments too ...

Ayende Rahien


a) To match the C# coding standard for 5.0

b) Because methods with the same name that does different things are VERY bad

smart guy

Now that's a combination... Silverlight and RavenDB. Somehow I've got impression that the NoSQL guys are also the NoSilverlight guys. Am I being wrong?

Jimmy Zimmerman


Rx is a great system no doubt but on the WCF layer of things the path forward is unequivocally TPL. End of debate. It makes sense therefore for Oren to take this route with the SL Raven DB client for no reason more than convention with the rest of the stack.

However that doesn't mean whatsoever that you cannot use Rx wrapped over TPL in your higher layers. There's some handy extension methods out there for doing just that. Simply put, IMHO Rx is best on the, well ..., reacting side of things. TPL is a better fit for the doing the thing itself.

Service Call = doing.

Updating the UI based on the call -> Rx to the rescue.


Ruben Bartelink

@Jimmy Zimmerman: Thanks for taking the time to lay it out that cleanly - makes sense.

I dont disagree with the perspective (reason I didnt respond to Ayende's response is that it's just correct!)

There's no doubt that, when compared to Rx, the Task <t stuff is

a) going to be native to SL in a future version

b) supported by he compiler enhacements

c) is simpler

d) is more likely to make it to the Phone (When you adding that, Oren? :P)

Therefore, unless one is going to get a significant benefit that outweighs the -100 points (@Raymond Chen) that adding another concept into the mix costs, sticking with the simplest thing definitely makes sense.

I was wondering purely about whether he'd considered/what his view was regarding the relative stability/availability of the relevant DLLs in question in the short to medium term and, implicit in that, whether he saw any angle/appropriateness for Rx when interacting with his lib making sense in any way.

Aaron Powell

There's a JavaScript API?

James Webster

Does RavenDB support deployment to Azure just yet? I know a patch was in progress, has it hit the main build?

Ayende Rahien


Yes, it does. It works a bit differently now, since we can be hosted in Azure, but it certainly works

Comment preview

Comments have been closed on this topic.


  1. The worker pattern - about one day from now

There are posts all the way to May 30, 2016


  1. The design of RavenDB 4.0 (14):
    26 May 2016 - The client side
  2. RavenDB 3.5 whirl wind tour (14):
    25 May 2016 - Got anything to declare, ya smuggler?
  3. Tasks for the new comer (2):
    15 Apr 2016 - Quartz.NET with RavenDB
  4. Code through the looking glass (5):
    18 Mar 2016 - And a linear search to rule them
  5. Find the bug (8):
    29 Feb 2016 - When you can't rely on your own identity
View all series


Main feed Feed Stats
Comments feed   Comments Feed Stats