Using LINQ to SQL with Silverlight

The previous sections described how Silverlight 2 client applications can serialize and consume POCO classes and classes decorated with the DataContract attribute. It is quite common to use a custom class and consume it from a Silverlight application. However, it is also common to use tools such as LINQ to SQL to act as a data layer for your application.

Building applications that use LINQ to SQL and WCF web services is not part of Silverlight 2, but it requires skills that intersect with Silverlight applications. These types of tools that gather data, process business logic, and provide a means of communication between the Silverlight client and a server are important pieces of a Silverlight application. This section will describe how to pass entities built with LINQ to SQL to and from a Silverlight application. The purpose of this section is to show how you can use object relational tools such as LINQ to SQL with Silverlight applications. Therefore, we will discuss only aspects that are critical to learning how to integrate LINQ to SQL with Silverlight.

LINQ to SQL Entity Serialization

When server objects are dragged to the designer, LINQ to SQL generates entities from them. The generated class can be serialized by default (now that it is no longer required that a DataContract attribute explicitly decorate a class, as discussed earlier in this chapter). Alternatively, the generated classes and their properties can be serialized out of the box by ...

Get Data-Driven Services with Silverlight 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.