Search and Find

Book Title

Author/Publisher

Table of Contents

Show eBooks for my device only:

 

Beginning Silverlight 2 - From Novice to Professional

of: Robert Lair

Apress, 2009

ISBN: 9781430205708 , 296 Pages

Format: PDF, Read online

Copy protection: DRM

Windows PC,Mac OSX,Windows PC,Mac OSX geeignet für alle DRM-fähigen eReader Apple iPad, Android Tablet PC's Read Online for: Windows PC,Mac OSX,Linux

Price: 35,30 EUR



More of the content

Beginning Silverlight 2 - From Novice to Professional


 

CHAPTER 6 Data Access and Networking (S. 117-118)

Data access in Silverlight applications works differently than it does in traditional applications. You’ll need to be aware of how it works and the limitations. In this chapter, we will look at what makes data access different, and then explore mechanisms for accessing data in a Silverlight application.

Data Access in Silverlight Applications


As discussed in Chapter 1, RIAs bridge the gap between Windows-based smart clients and web-based applications. When moving to this type of environment, data access and networking can be confusing. In a Windows-based smart client, the application has access to the database at all times. It can create a connection to the database, maintain state with the database, and remain connected.

On the other hand, a web application is what is known as a pseudo-conversational environment, which is, for the most part, a completely stateless and disconnected environment. When a client makes a request to the web server, the web server processes the request and returns a response to the client. After that response has been sent, the connection between the client and the server is disconnected, and the server moves on to the next client request. No connection or state is maintained between the two.

In Silverlight applications, we have one additional layer of complexity. The application runs from the client’s machine, however, it is still a disconnected environment, because it is hosted within a web browser. There is no concept of posting back for each request or creating a round-trip to the server for data processing. Therefore, data access is limited to a small number of options.

In addition, a Silverlight application has a number of security restrictions placed on it to protect the users from the application gaining too much control over their machine. For instance, the Silverlight application has access to only an isolated storage space to store its disconnected data. It has no access whatsoever to the client’s hard disk outside its “sandbox.” Silverlight’s isolated storage is discussed in more detail in Chapter 7.So what are your options for accessing data in a Silverlight application? The following main mechanisms are available:

• The most common mechanism to access data from a Silverlight application is through web services, typically a WCF service.
• Silverlight applications can access data using ADO.NET Data Services, which provides access to data through a URI syntax.
• Silverlight 2 also has built-in socket support, which allows applications to connect directly to a server through TCP sockets.
• Silverlight 2 has out-of-the-box support for JavaScript Object Notation (JSON), as well as RSS 2.0 and Atom 1.0 syndication feed formats.

Of these mechanisms, we’ll explore accessing WCF services from Silverlight 2 in depth, and then have a high-level look at using sockets. For examples and more information on accessing other data services, refer to Pro Silverlight 2 in C# 2008 by Matthew MacDonald (Apress, 2008).