A Simple approach to build a Silverlight 3.0/Silverlight 4.0 application that consumes a WCF Service
Silverlight has been around for quite some time now and I hope most of you who have been working on Silverlight 3.0, might have started migrating to Silverlight 4.0. As you are aware, Silverlight is now used for developing LOB applications where the requirement is to develop loosely coupled browser based applications using Silverlight.
One of the approaches here is to remove the dependency between Model and View (UI) so that they can be developed and tested independent from each other. This article shows how to create a Silverlight application that consumes a WCF service keeping minimum dependencies between the Model and ViewNote.
This article does not use the MVVM approach as indicated earlier. Check out the MIX session by Laurent to know more about building MVVM applications by visiting http://live.visitmix.com/MIX10/Sessions/EX14
In this article, I have used WCF service which is responsible for Database communication. You can use ADO.NET entity framework and ADO.NET Data service instead of writing data access code in WCF, but we will leave that to a different article.
Note: In this article I have used VS2010 RC, WCF 4.0 and Silverlight 4.0.Step 1: Open VS2010 and create a blank solution, name it as ‘SILV4_MVVM’.Step 2: To this solution, add a WCF application project, name it as ‘WCF_DataService’. Rename ‘IService1’ to ‘IService’ and ‘Service1.svc’ to ‘Service.svc’.Step 3: To this WCF Service project, add a new class and name it as ‘DbManager’.
This class will act as a Database communication class. Write the implementation of the class as shown below
View the Original article