As a Silverlight newbie, I am finding it really hard to set up an RIA Web service. The examples available on the web almost always refer to Entity framework as the ORM but we are using NHibernate as our ORM. I am aware of the tutorial by Brad Abrams where he uses NHibernate as the ORM but most of it goes above my head because I am also a newbie at NHibernate and some of the concepts of RIA are not clear to me e.g. DomainService.
I'd like to first keep it simple and ignore the ORM at the moment. So, can anyone point me in the right direction as to how to get a "vanilla" web service going with Silverlight 4.0 and the latest release of RIA? For instance, how would I expose a method which returns the integer 100 and then call the method from my SilverLight application? Also, I am not sure if it's relevant or not but the Silverlight application is hosted in ASP.NET MVC 2.
To me it should be so simple but I'm really struggling with it at the moment.
TIA,
David
These scenarios (non-EntityFramework RIA Services with Silverlight) are definitely under documented and I hope to post some blog entries soon to cover these scenarios (including how to use NHibernate).
Here is one way to do what you are asking:
Install "Silverlight 4 Tools for Visual Studio 2010" if you haven't already:
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=b3deb194-ca86-4fb6-a716-b67c2604a139&displaylang=en
Create a new Silverlight Navigation Application in Visual Studio 2010 (check the box to enable RIA Services).
Modify the web.config in the web project in the following ways:
In the <system.web> section, add:
Add a <system.serviceModel> section as a peer of <system.web>:
Add the following references to the web project:
Create a new class VanillaDomainService in the web project that contains your "return 100" method:
Now back to the Silverlight Application project, in Home.xaml.cs, in the OnNavigatedTo method, call your new RIA Services method (remember all calls are async):
Now build and run and that should be it.
I tested this code and it worked for me.