Several months ago the guys from Microsoft announced that they are developing a framework for developing Business applications under Silverlight with the codename Alexandria and now it's a reality! On the MIX'09 session a release of it under the name WCF RIA Services was announced. The possibilities that the framework are really great and allow the Silverlight developers to easily develop business application in a much easier and faster way.
I am starting this series of articles in order to introduce the main features of the WCF RIA Services framework. The first articles are concerning more trivial things, but the deeper we go in the framework the more interesting it will get. In this article I'll make an overview of the main features of the framework and will describe a sample application that I will try to create with it.
Features
Those of you who have previously worked with ASP.NET will be positively surprised by the most of the features. A lot of goodies from the ASP.NET are now available under Silverlight, thanks to the new release of Silverlight 3 and the WCF RIA Services.
The Silverlight Application project
The first thing you should know about the WCF RIA Services is that they don't use a special project template, but use the default "Silverlight Application" one. Of course there are some modifications made to it, in order to work with the framework.
If you select the client Silverlight project and click on the "Show All Files" icon in the solution explorer, you will see a GeneratedCode folder. It is used by the server project to generate or copy parts of code on the client, that can later be used in the client application. There is no need to include this folder in the project, also do not add these files under source control, because they are dynamic and are generated on every build. In one of the next articles we'll see which code gets included on the client.
DomainService
If you take a quick look at the "New Item" templates in the Visual Studio you will notice a new one - the Domain Service Class. The class created inherits from the DomainService class and will be your main container for business logic while developing with the WCF RIA Service framework. It's one of the classes which content is generated on the client.
Shared files
The code files marked with "shared" in their name (MyClass.shared.cs) are directly copied in the GeneratedCode folder on the client. Be careful though, not everything that is available on the server is available on the client!
DomainDataSource
Do you remember the ObjectDataSource in ASP.NET? Now we have one in Silverlight too! The control is called DomainDataSource and can use a DomainService class in order to load and modify information. It also provides some cool features - you can load the information from the server in pieces. Read more about that in one of the next articles.
Sorting, filtering and paging
Actually the sorting and the filtering is functionality of the DataSource, but I think I can dedicate a separate article to them. When using sorting and/or filtering they are applied to the collection that the DataSource has loaded. The paging is part of Silverlight 3 and works with any control that has a collection of items for its source, so I think it do some nice work together with the DomainDataSource.
Authentication and Roles
The Authentication and Roles services from ASP.NET are now implemented by default in the Silverlight application, which means that they are ready to use and you don't have to create any service or add service references.
The Demo Application
To demonstrate all of the features of the WCF RIA Services and some of the new features of Silverlight 3, I've decided to recreate the ASP.NET Web Administration Tool. Of course it's much more simplified and allows some basic actions like displaying information, modifying it, adding new one to a DataBase. It has in itself all the stones needed to build a base for a business application and also explains the basics around the new framework.
Here is link to the demo and the source code to it. Note the it will be extended with every article of the series.
Conclusion
With the release of Silverlight 3 and the WCF RIA Services framework we are now able to create much more functional and interactive applications in less time. There were a lot of questions about Silverlight and Business applications in the past, now we have an answer from the Silverlight team .Probably it won't answer all the questions at once, but at this time it's great to know that the creating of Business applications under Silverlight is easier and faster!