PDC09 and MIX10 announced two major messages, namely the Silverlight 4 Beta and RC. When you read this article, the Silverlight 4 full version published to the Web is already available for download. In addition to extensive print support, it also supports permission upgrades, webcam, microphone, toast, clipboard access, and so on. With its all-new feature set, Silverlight 4 is a multi-platform, rich UI framework that can handle the head-on confrontation with Adobe AIR.
While I'm really excited about all of this, my main role is a business application developer, and my focus is on using an easy way to integrate my business data and logic into Silverlight applications.
For Silverlight line-of-business applications, one of my concerns is how to connect to data. Creating your own Windows Communication Foundation (WCF) service in Silverlight 3 and connecting to the service is not a hindrance. However, there is much room for improvement in this version, especially when connecting to data from a asp.net or desktop application, which needs to be improved. Desktop applications and WEB applications can be directly connected to the database through Nhibernate, the Entity Framework (EF), or the original ado.net structure, but the Silverlight application is blocked from my data by the cloud. I refer to this barrier as the "data divide".
Crossing this chasm may at first glance be very simple. It is clear that there are now many data-rich Silverlight applications that have somehow achieved this leap. But initially seemingly simple tasks become more complex as you solve more problems. How do I track changes over the network? How do you encapsulate business logic within entities that are located at both ends of the firewall? How do I prevent transmission details from leaking your business-sensitive information?
There are a growing number of third-party tools to address these issues, but Microsoft also found that a solution was needed to provide a WCF RIA service (formerly known as. NET RIA Services), or RIA services. RIA Services is fully described in the May 2009 edition of MSDN Magazine's "build data-driven expense application using Silverlight 3" (msdn.microsoft.com/magazine/dd695920). From the first time I was invited to participate in the Beta program, I've been focusing on RIA services, building suggestions to the development team, and learning how to apply the framework in my own applications.
A common problem in the RIA Services forum is how RIA services fit into the best practices architecture. I've always been impressed with the basic features of the "Data based form Design" of RIA services, but I did see an opportunity to improve my application architecture, so the framework issues didn't affect my application logic.
Kharapos Introduction
I developed a sample application: Kharapos, designed to provide a relevant example of the concepts I am presenting in this article. This example is a point-of-sale (POS) application that uses RIA services, the Entity Framework, and SQL Server 2008 implemented in Silverlight 4. The ultimate goal is to enable the application to be hosted on Windows Azure platform and SQL Azure, but the Windows Azure platform's support for Microsoft. NET Framework 4 is problematic (not even supported).
During this transition period, kharapos can serve as a good example of creating an actual application using the. NET Framework 4. The project is placed in the KharaPOS.codeplex.com through CodePlex. You can download code from the site, view the documentation, and join the discussion about developing this application.
What I want to illustrate is that for most of the design and functionality of the Kharapos application, I borrowed the object model: strategy, patterns, and Apps, 2nd edition, co-authored by Peter Coad, David North, and Mark Mayfield (Prentice Hall ptr,1 996). I will focus on one subsystem of the application: the Directory management system (see Figure 1).
Figure 1 The Entity Data Model of the Directory management system