Tag Archives: WCF RIA Services

Slides and samples from Silverlight Patterns and Frameworks talk

8 Feb

Yesterday Martin Jespen and I did a talk about Silverlight patterns and framework at the monthly Silverlight Usergroup meeting in Denmark.

I the first part of the talk, Martin showed the differences between MEF and Unity and wrapped up by showing some of the possibilities in PRISM. You can download the samples here. You can download the documentation for PRISM here.

In the second part of the talk, I showed how to expose an OData feed using a WCF DataService and access the data from a Silverlight application. To follow up I showed how to use a WCF RIA Service and how to expose the data as an OData feed. You can down the samples here. You can find a guide to OData and Silverlight here.

You can download the presentation here.

by xamlgeek 

Slides fra talk om WCF RIA Services hos Dansk IT

1 Dec

Jeg afholdte i formiddags en 3-timers talk om WCF RIA Services hos Dansk IT. Der var en virkelig god dialog og der kom nogle gode (og afklarende) spørgsmål.

Slides og demoer (inklusive custom validation) kan downloades her:

by xamlgeek

Use DomainServices as Service References

30 Nov

DomainServices was introduces as part of WCF RIA Services. WCF RIA Services offers a solution on how we can build a middle-tier having clients and servers.

Using a DomainService in a Silverlight client is very easy using WCF RIA Services – the WCF RIA Services link between the client and the server will automatically generate the client side code that we need to communicate with the server.


To avoid writing middle-tier functionality more than once we want to be able to reuse the DomainService and the logic inside of it to all of our projects. Most project types beside Silverlight do not understand WCF RIA Services yet. But as a DomainService ultimately just is a WCF Service we can just make a normal Service Reference (or ChannelFactory) to it and reuse the logic.

For that to work you need to make a few adjustments to the project hosting the service. When you add a DomainService to your project a DomainServiceHttpModule http module is added to your web.config and ASP.NET compatibility is turned on.


The DomainServiceHttpModule dynamically generates a WCF Service based on our DomainService. In this sample I have added a DomainService called DomainService1 in the root of my ASP.NET web project called WebApplication1. The web project is using port 6479. Based on this information I can point to my dynamically generated WCF Service from my browser:



If I try to make a Service Reference to the WCF Service I will get an error:

There was no endpoint listening at http://localhost:6479/Services/WebApplication1-DomainService1.svc that could accept the message.

Before I can make a Service Reference to the service I need to define an endpoint in the web.config. First I need to add a custom configuration section for DomainServices within System.ServiceModel.


Using the RIA Services Toolkit I can now define a SOAP endpoint (I need to add a reference to Microsoft.ServiceModel.DomainServices.Hosting found in the Microsoft SDKs/RIA Services/v1.0/Toolkit/Libraries folder).


Finally I can add a Service Reference to the service and use it as if it was a regular WCF Service.



You can download the full sample from http://bit.ly/dOVMVR.

by xamlgeek

Properties in WCF RIA Services – using LINQ-to-SQL

28 Feb

I have previously written a post about including properties in WCF RIA Services. The post was using POCO as business model. If you use LINQ-to-SQL as your business model you might need some extra load options to get your associated properties sent from the server to the client.

You can add the extra load options in the domain service methods on the server. In my previous post I use two entities; a Company and an Employee entity. The Company entity has a Employee property called CEO.

First you need to add a reference to System.Data.Linq and add a using in the BusinessService.


Second you need to add the load options. In this case you want CEO to be loaded when the Company is loaded.


Finally you set the load options to the DataContext and then you’re ready to return your data as normal.


(In the code above I get an error on the DataContext; don’t mind that – it’s just because I used the sample code from the previous post that don’t use LINQ-to-SQL and there don’t recognize the DataContext object.)

by xamlgeek

Include related properties in WCF RIA Services

21 Feb

WCF RIA Services provide lots of possibilities on getting data from the server to the client whether it is a Silverlight client or a console application.

One of the challenges that you may experience using WCF RIA Services is getting related properties to an entity to be included on the client. But no need to get scared – it is actually pretty easy.

First of all you need to create an association between your entity and the related entity. Lets say we have a company (Company) with a CEO (Employee):



When we get a list of companies from the client we would like to have the CEO property included and filled on the company. To do that we need to add a few attributes to the CEO property. Instead of adding the attributes on the entity object we can create a metadata file that holds this type of information.


Now the CEO property will be included, filled and ready to use when we call a query from the client that returns a list of companies.

You can download sample from my DropBox: http://dl.dropbox.com/u/4243120/SL%20Demos/RiaIncludePropertiesDemo.zip

by xamlgeek