Creating Silverlight programs using LINQ and Ado.net

Source: Internet
Author: User

Industry and other data-centric applications can be created in Silverlight, but processing data in Silverlight is not an easy task, since Silverlight includes many tools for processing data and supporting Web services and XML. However, these tools represent only the most basic part of data access across firewalls.

Common data access policies are implemented using Web service and client LINQ, and if you are modifying existing Web service endpoints to harden your Silverlight applications, then I recommend that you use this approach. But if you are using Silverlight to create a new Web Service, there is no need to do so.

For a typical Web service layer, you implement a traditional data access policy (Custom business object, LINQ to SQL, Entity Framework, nhibernate, etc.) on the server to expose data objects through Web service, web Service is just the gateway under the data Access policy.

But to turn on full data connectivity, you have to map four data operations (create, read, update, delete) to the Web service method, and here is a simple service contract that supports the product class, and note that I use C # in this article.

Example 1 service Contract for Product Web service

[ServiceContract]
public interface ICustomerService
{
  [OperationContract]
 List GetAllProducts();
  [OperationContract]
 Product GetProduct(int productID);
 [OperationContract]
  List GetAllProductsWithCategories();
  [OperationContract]
 Product SaveProduct(Product productToSave);
  [OperationContract]
 void DeleteProduct(Product productToDelete);
}

Creating a set of services to handle an application's complete data model can be quite time-consuming, as shown in this example, the operation of special features can lead to a very bloated web service, in other words, the Web service will have new requirements and operations to increase, even including operations that are not part of the core business domain.

In Example 1 you see that the getallproductswithcategories operation is used by default to retrieve the product and the taxonomy. Even if you add a sort, filtering and paging mechanism to this simple example you should not be surprised if there is a simple way to support data operations (such as queries, sorting, filtering, etc.) without having to manually build these mechanisms every time it will be very appealing, ado.net Data service is born for this.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.