Why Expose Data from the Server via Services

If you're used to writing applications that communicate directly with a database (such as SQL Server), you might be surprised to find that there is no object in Silverlight to enable you to do so (SqlConnection, OdbcConnection, etc.). This is because Silverlight is a client platform, designed to be run from within a browser anywhere in the world, and so it does not make sense for it to be able to access databases

directly because databases are generally hidden behind a firewall. The purpose of a service is to provide an interface for exposing data publicly from the server, acting as a conduit between the data in the database and external applications.

In addition to exposing data from the server, services also enable you to do the following:

  • Specify the types of operations that can be performed on the data
  • Execute logic as a part of these operations
  • Implement security, deciding what data can be exposed to whom, and who can perform what operations on the data

.NET applications typically use Windows Communication Foundation (WCF) Services to implement these services. WCF RIA Services is a layer on top of WCF, providing enhanced functionality and structure for consuming data in your Silverlight applications. Although this chapter will primarily focus on RIA Services, it's worth taking a look at its underlying WCF foundation first. Before we do that, we need a source of data to expose from the server, so let's set up a database and make it available to our AdventureWorks.Web project.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset