Why does Microsoft push ADO. NET data services?

Source: Internet
Author: User
Tags dotnet representational state transfer visual studio 2010

On the. NET 3.5 SP1 platform, Microsoft pushed a new set of data access frameworks called ADO. NET data services. Microsoft fearProgramIs the staff too idle? Why do we need to create ADO. NET data services? Does web service and WCF work well? In this post, I will sort out some ideas from seminars and online experts, and provide an example that can be executed on vs 2008 SP1 for your reference; however, this post does not provide step by step teaching because there are already a bunch of suchArticle(Refer to the "reference files" Article at and at the bottom of this post, and follow the operations with vs 6th + SP1 to provide download examples for the cost post ).

. Net's WCF 3.5 has a very important new function that supports rest (representational state transfer. I have heard that some well-known large websites and ror camps have begun to gradually abandon web services and provide rest services. So Microsoft cannot be idle here, and it has developed a set of ADO. NET data services to support the concept of rest.

The so-called rest, literally, is to allow developers and applications (including applications on heterogeneous platforms, of course) to be simple to no longer simple, access and retrieve network data and resources. What is a simple method? Rest uses the simplest URL, so that general customers and applications can directly access and write databases on remote hosts. In addition, Microsoft implements the rest ADO. NET data services and has a set of security control and access permission control mechanisms, so you do not have to worry about security issues.

Compared with Microsoft's WCF Service, and the Web service that is commonly used in the past, the two are similar to rest and ADO. compared with net data services, it is relatively complex and not flexible enough, and the Web service has the most serious performance problems.

In the past, if you were a company's MIS, when a department a's employees needed some data, you may write a web service to open the data for others; after a while, the Supervisor of department B needs other data. You may write another Web Service and open the data in another host database to others. Over time, hundreds of web services may be difficult to maintain and manage, so it is not flexible enough. In addition, when others call these web services, they must first know the host location, function name and function, input parameters and types, which is not convenient enough for reference.

However, if you use rest, ADO. NET data services, when you want to publish the database northwind on a host, when accessing remote users, developers, or applications (including select, insert, update, delete, and other crud actions), you only need to provide the following URLs with HTTP verbs (get, post ,...) you can:
Http: // www. website name. com/northwind

To allow them to access the Products table in the northwind database, you only need to provide the following URL:
Http: // www. website name. com/northwind/products

That is to say, ADO. NET data services is an "Intermediary Service" for remote host data access. It can be determined by the client and client applications on their own.

Therefore, in the future, the URL is no longer just a web site, but may be a database, data source, or cloud computing [, 17]; in addition, for Ajax, WCF, Silverlight, and other client applications in a distributed environment, using this rest-based service is also quite simple, especially Ajax does not need to create a bunch of JavaScript manually; in the future, data exchange between heterogeneous systems will lead to more convenient and easy-to-use options than Web services. The desperate programmer may be able to rest in the future (although it is actually just a dream ).

In. NET platform, the future.. NET Framework 4.0 and Visual Studio 2010 still have ADO. net Data Services Framework 2.0, and a new 4.0 version of system. data. services function library, so we estimate ADO. NET data services should not be eliminated by Microsoft in the future, so programmers can learn with confidence.

-------------------------------------------------
Example of this postCodeDownload point:
Http://files.cnblogs.com/WizardWu/081214.zip

(In this example, vs 2008 + SP1 and SQL Server's northwind database are required. If it cannot be executed, please leave a message in this post)
-------------------------------------------------

This example is based on the teaching practice of articles 6th and 7th in the "reference document" at the bottom of this post. We will not repeat the process here. After downloading the code, double-click testds. sln to start two projects with vs 2008 (SP1), as shown in figure 1.


Figure 1 "webdataservice. SVC" refers to the data services that are opened in a URL and referenced by all customers.

Figure 1 The ds_server project below is the ADO that provides services. NET data services, through an O/R Mapping EDM file [2], and ADO. NET Entity Framework provides customers with access to the northwind database of SQL Server 2005.

Like WCF, ADO. Net Data Services also provides network services in. SVC format. For example, 1. In vs 2008, right-click and open webdataservice in the browser. SVC file, you should see the figure 2, that is, list all the table names in the northwind database.


Figure 2 by default, ADO. NET data services will return all data in XML/atom format.

Assume that you have enabled the following URL:
Http: // localhost: Port Number/ds_server/webdataservice. svc/

In this case, you only need to add the table name to the end to select all the contents of the table. The following syntax is used to retrieve the content of the entire Products table and return it in XML/atom format:
Http: // localhost: Port Number/ds_server/webdataservice. svc/products

If you cannot see the content of 2 in IE, because it is returned in atom format, the browser will automatically format the content. For example, 3 (using ie 7.0 as an example), disable the automatic formatting action in the browser, and then press F5 to reorganize the webpage:


Figure 3 in IE 7, deselect "Start abstract read view 」

Next, you (and all clients and client programs) can directly execute various ADO. Net Data Services Query syntaxes through this URL. For example, the following syntax is used to retrieve the first record in the table:
Http: // localhost: 1056/ds_server/webdataservice. svc/products (1)

The following syntax is used to retrieve the record's productname field storage value (which can be executed on FireFox 3.x after a trial ):
Http: // localhost: 1056/ds_server/webdataservice. svc/products (1)/productname

The following syntax identifies all order data with customerid "alfki" in the orders table:
Http: // localhost: 1056/ds_server/webdataservice. svc/Mers MERs ('alfki')/orders
The result shows six records. Its syntax is equivalent:
Select * from orders where customerid = 'alfki'

Of course, you can also set various parameters, such as top, orderby, filter (greater than, less than, equal to, not equal to), skip, and expand. The top 20 pieces of data in the table can be retrieved using the following syntax:
HTTP: /localhost: 1056/ds_server/webdataservice. svc/products? $ Top = 20

Of course, you can also use some logical operators, mathematical operators, and curd operations. However, currently, sum, Min, Max, and AVG functions are not supported, and aggregate functions, isnull, and coalesce operators are not supported, however, it has a null comparison syntax, such as the following syntax. To retrieve records in the products table where the content of all unitprice fields is not null:
HTTP: /localhost: 1056/ds_server/webdataservice. svc/products? $ Filter = unitprice ne null

For more information about its syntax, refer to the reference file [11] below this post and the file on the network. In addition, ADO. NET data services has a security control mechanism. For example, only some accounts can retrieve certain tables, and users in a group have the permission to write data to the database. programmers do not have to worry about security issues.

Next, we will mention that if this data service is to be used by the client, you certainly cannot lose a URL and ask him to go to the query syntax. Therefore, each programmer must write a client program to call this service. Refer to Figure 1 in this post. In vs 2008, set the ds_client project above to "Start Project", and then view the program in this project. CS code, such as 4. Change the port number next to localhost to webdataservice in your browser. in SVC, the port number randomly assigned by the virtual web server in vs 2008. After the bucket is changed, press F5 to directly execute the ds_client project. The Console mode execution screen in the lower-right corner of Figure 4 is displayed, the webdataservice in the ds_server project is referenced first. SVC service, and then access the Products table using C #3.0's LINQ, and list the content values of the two fields.


Figure 4 using LINQ and EDM for o/R Mapping, client programs and programmers do not need to know where the backend database is located and How to Write SQL statements

 

Conclusion:

As the title of this post, why does Microsoft create ADO. NET data services framework? This technology and the concept of rest are designed to "simplify" The work of programmers. When performing data exchange in a distributed environment or on a heterogeneous platform, as long as the existing HTTP protocol and Uris URL are used, it can provide more simple remote Program Calling capabilities than Web Services. ASP. NET Ajax 4.0, Silverlight 2.0, and vs 2010 support ADO. NET data services, and even Microsoft's "Azure service" in the future. In the future, Microsoft may want to expand its ambition to allow enterprises to manage their application systems as much as possible by Microsoft. Through cloud services and data services, enterprise users may feel convenient and cost-effective, therefore, large enterprises and IT practitioners will be more difficult to break away from the control of the Microsoft empire in the future.

------------------------------------------------------------

Reference file:

(1) ADO. NET data service framework (msdn)
Http://msdn.microsoft.com/zh-cn/library/cc668792.aspx

(2) EDM Entity Data Model (msdn)
Http://msdn.microsoft.com/zh-cn/library/bb387122.aspx

(3) ADO. Net Data Services Framework Seminar (Traditional Chinese)
Http://blog.sina.com.tw/dotnet/article.php? Pbgid = 4907 & entryid = 580166

(4) Rest ~ Mood From Web service to restful WCF (Traditional Chinese)
Http://studyhost.blogspot.com/2008/11/rest.html

(5) use WCF to develop restful services (Traditional Chinese)
Http://studyhost.blogspot.com/2008/11/wcfrestful.html

(6). Net magazine International Chinese electronic version, November October 2008 (Traditional Chinese)
Http://www.netmag.com.tw/

(7) ADO. NET data services experiment test (Traditional Chinese)
Http://blog.yam.com/kaizan/article/17120397

(8) getting started with ADO. NET data services)
Http://codebetter.com/blogs/david.hayden/archive/2008/01/08/getting-started-with-ado-net-data-services.aspx

(9) Learn Silverlight step by step: Ado. NET data services for data and communication
Http://kb.cnblogs.com/page/42890/

(10) use ADO. NET data service (Astoria) for data CRUD operations
Http://www.cnblogs.com/lyj/archive/2008/04/11/1149136.html

------------------------------------------------------------

Related Files:

(11) A simple solution for addressing data using a uniform uri (ADO. NET data service framework)
Http://msdn.microsoft.com/zh-cn/library/cc668786.aspx

(12) system. Data. Services. Client namespace (msdn)
Http://msdn.microsoft.com/zh-cn/library/system.data.services.client.aspx
Http://msdn.microsoft.com/zh-cn/library/system.data.services.aspx

(13) restful. net
Http://oreilly.com/catalog/9780596519209/

(14) Representational state transfer (rest)
Http://www.ics.uci.edu /~ Fielding/pubs/Dissertation/rest_arch_style.htm

(15) cloud computing (Traditional Chinese)
Http://jerrylovesrebol.blogspot.com/2008/12/blog-post_02.html

(16) Overview of Visual Studio 2010 and. NET Framework 4.0 in the cloud computing generation (Traditional Chinese)
Http://blog.sina.com.tw/dotnet/article.php? Pbgid = 4907 & entryid = 580518

(17) Microsoft Azure cloud service platform I-view the benefits of azure cloud services (Traditional Chinese)
Http://blog.sina.com.tw/dotnet/article.php? Pbgid = 4907 & entryid = 580717

------------------------------------------------------------

 

 

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.