Hi all,
I’ve previously blogged about how mind blowing WCF RIA Services are here
This week i found myself working with RIA Services again and this time I’ve got to show you just how easy it is (is case you didn’t take my advise and go look it up 
So, fire up VS2010 and create a new Silverlight Business Application

Two projects will be created for you, the Web project is where your DataAccess and Business logic lies, the other project is your Silverlight application.
Create an entity framework model ORM for your data (you know how to do this right?)
Next create a new Domain Service Class in the Web/Services folder


Compile.. that’s your server ready to serve up your data.
Now lets move into the Silverlight app, and add the following mark-up to your xaml
First add the domain datasource, set it to auto load and set the Query name to the name of the query that has been injected into your client app, (let intellisense help you; it will be in the Web.Services namespace context object.
<domainControls:DomainDataSource x:Name="dataPads" LoadSize="20" AutoLoad="True" QueryName="GetPadocks">
<domainControls:DomainDataSource.DomainContext>
<data:FarmContext />
</domainControls:DomainDataSource.DomainContext>
</domainControls:DomainDataSource>
Add a datagrid use ElementBinding to the domainDataSource above (i’ve also put it in a telerik busyindicator to provide feedback that the data is loading)
<telerik:RadBusyIndicator IsBusy="{Binding ElementName=dataPads, Path=IsLoadingData}">
<dataControls:DataGrid x:Name="padocksGrid" MinHeight="100"
ItemsSource="{Binding ElementName=dataPads, Path=Data}" />
</telerik:RadBusyIndicator>
Ok I’ve once again skimped on some of the detail but it’s a really nifty approach and i encourage you to give it a go.
(Also seeming your service is a DomainContext you can expose your data as OData a post for another day
)
Now there’s a pretty sweet way of looking at what’s happening on your server, I’ve picked this tip up from watching SHanselmans MS Stack Of Love (recommended watch) @ MIX11 this year.
Here’s how, (pardon the screenshot file sizes as usual ..)
1) Create an application

2) Add a package

3) Search online for glimpse and install

4) Add at least one Trace to demo an additional Glimpse feature

5) Fire up your app and go to <appurl>/Glimpse/Config, and Turn Glimpse On

6) Click on the beady little eye on the bottom right corner of your webpage

7) Voilá


I’ve been playing (seriously playing) with Visual Studio LightSwitch for the last few weeks and I have to say it’s knocking my socks off, not since I programmed in MS Access (am I allowed to say that? Should I even admit where it all started for me back in 1995….), anyway,,, not since I programmed in MSAccess have I really seen a real a tool that really puts the R into RAD when it comes to small system data managment.
So now I want to publish my efforts as I’ve suckered a friend into some peer review, I could publish it to one of my webservers, manually set up a Sql Database etc (don’t have lightswitch deployment support on any of my servers just yet); but this Azure option was just too tempting.

Ok.. it didn’t take 15 minutes (more like 10) but I’ve now got access, hopefully I’ll do a follow up after I publish the final version of my app… stay tuned..

WCF not only provides SOAP, it’s also capable of providing RESTful services through use of the WebGet and WebInvoke attributes in the System.ServiceModel.Web assembly in conjunction with the webHttpBinding and webHttp behaviour. In fact, WebGet/WebInvoke are not really required required (however PUT is the default Http Verb and you won’t be able to specify what methods correspond to urls.
Here’s a sample;
[ServiceContract]
public interface IPersonInfo
{
[OperationContract]
[WebGet(UriTemplate = "/Details")]
string Details();
[OperationContract]
[WebGet(UriTemplate = "/Person")]
Person GetRandomPerson();
[OperationContract]
[WebGet(UriTemplate = "/Person?format=xml", ResponseFormat = WebMessageFormat.Xml)]
Person GetRandomPersonXml();
[OperationContract]
[WebGet(UriTemplate = "/Person?format=json", ResponseFormat = WebMessageFormat.Json)]
Person GetRandomPersonJson();
}
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class PersonService : IPersonInfo
{
public string Details()
{
WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.OK;
return "Mon-Fri 9am to 5pm";
}
public Person GetRandomPerson()
{
return new Person { Address = "Limerick", Name = "Brian", Country = "Ireland" }; // not so random..
}
public Person GetRandomPersonXml()
{
return new Person { Address = "Limerick", Name = "Brian", Country = "Ireland" }; // not so random..
}
public Person GetRandomPersonJson()
{
return new Person { Address = "Limerick", Name = "Brian", Country = "Ireland" }; // not so random..
}
}
Host this service in IIS for example and you’ll be able to get the following results

As REST support only arrived in WCF 3.5 there is still a lack of support in certain areas, e.g. error handling, caching etc; what I’ve seen done in practise is people continue to use the REST Starter kit from codeplex.
Not many comments needed I imagine.
The “ThenBy” extension method is what you’re looking for.
