简体   繁体   English

WCF REST与ADO.NET数据服务

[英]WCF REST vs. ADO.NET Data Services

Could someone compare and contrast on WCF Rest services vs. ADO.NET Data Services? 有人可以比较和对比WCF Rest服务与ADO.NET数据服务吗? What is the difference and when to use which? 有什么区别以及何时使用哪个?

Thanks, 谢谢,

Ray. 射线。

Edit : thanks to the first answer, just to give a bit background on what I'm looking to do: I have a web app I plan to put in the cloud (someday), the DAL is built with ADO.NET Entity Framework. 编辑 :感谢第一个答案,只是为了给我一些关于我要做的事情的背景:我有一个我计划放入云端的Web应用程序(有一天),DAL是用ADO.NET Entity Framework构建的。 And, I need to figure which web service data access technology would best fit my case. 而且,我需要确定哪种Web服务数据访问技术最适合我的情况。

Not sure I can give a complete answer here but I spent a lot of time at PDC trying to figure this out myself so here's a go... 我不确定我能在这里给出一个完整的答案,但我花了很多时间在PDC试图弄清楚这一点,所以这里是一个...

The short answer here is that ADO.Net Data Services are meant to provide an interface to the ADO.Net framework (DataContext, Datasets, DataTables etc…) that is seamlessly integrated with the web, using URIs and well-known data to point to your Data. 这里简短的回答是,ADO.Net数据服务旨在为ADO.Net框架(DataContext,Datasets,DataTables等)提供一个接口,该框架与Web无缝集成,使用URI和众所周知的数据指向你的数据。 ADO.Net Data Services are also meant for programming ADO.Net in the cloud. ADO.Net数据服务也用于在云中编程ADO.Net。 Microsoft's Cloud services, "Azure", is a new cloud programming platform that will be release in the near future. 微软的云服务“Azure”是一个新的云编程平台,将在不久的将来发布。 For more info on Cloud Services go here . 有关云服务的更多信息,请访问此处

One cool thing I found out about ADO.Net Data Services and the cloud is that the underlying DataContext that acts as the provider to your data source can be easily configured to point your resource in the cloud, or , an on premise database. 我发现有关ADO.Net数据服务和云的一个很酷的事情是,作为数据源提供者的基础DataContext可以轻松配置为将您的资源指向云本地数据库。 This allows you to switch your DataContext without changing any code!!! 这允许您在不更改任何代码的情况下切换DataContext! (I was impressed by that if you couldn't tell) (如果你不知道的话,我印象深刻)

WCF Rest Services are just normal WCF Services that have added functionality so that they can be consumed in a RESTful manner (URI vs URL, Usage of HTTTP Verbs, Usage of Different Data Transfer Formats like JSON, YAML, etc...). WCF Rest服务只是普通的WCF服务,它具有添加的功能,因此可以以RESTful方式使用它们(URI与URL,HTTTP动词的使用,JSON,YAML等不同数据传输格式的使用等)。 So for example, if you had a stock ticker web service that you built in WCF, instead of requiring the caller to use a heavy WSDL implementation and ASMX, you could just use the WCF Rest functionality to publish that service as a JSON service instead and have it consumed via AJAX without having to point to an ASMX resource. 因此,例如,如果您有一个在WCF中构建的股票行情Web服务,而不是要求调用者使用繁重的WSDL实现和ASMX,您可以使用WCF Rest功能将该服务作为JSON服务发布而不是通过AJAX消耗它而不必指向ASMX资源。 For more info on WCF using rest check out the PDC Presentation 有关WCF使用休息的更多信息,请查看PDC演示文稿

If you want to develop and deliver a data centric service, in certain cases a lot of functionalities can be achieved by both the WCF rest starter kit and WCF data service, as both of these technologies of WCF can deliver your data in a RESTful way (eg with addressable content with URLs and standard formats of data such as xml and json). 如果您想开发和提供以数据为中心的服务,在某些情况下,WCF休息入门套件和WCF数据服务都可以实现许多功能,因为WCF的这两种技术都可以以RESTful方式提供您的数据(例如,具有URL的可寻址内容和诸如xml和json的标准数据格式。 They also both equip with an array of .NET classes for dealing and handling a lot of network and web requests such as HTTP interceptors and cache. 它们还配备了一系列.NET类,用于处理和处理大量网络和Web请求,例如HTTP拦截器和缓存。

However, one advantage that WCF data service owns but not the REST starter kit is that WCF data service can expose its data in the form of .NET entity objects and in standard formats(this is achieved by the OData protocal). 但是,WCF数据服务拥有但不支持REST入门工具包的一个优点是WCF数据服务可以以.NET实体对象标准格式的形式公开其数据(这是通过OData协议实现的)。 So I guess WCF data service would give you more versatile performance in a lot of real world scenarios. 所以我想WCF数据服务可以在很多现实场景中为您提供更多功能。

Thank you so much for the insight! 非常感谢您的见解! For my app, I do plan to put it in the cloud and I also used ADO.NET Entity Framework to build my DAL, so it sounds like ADO.NET Data Services is the one for me to choose. 对于我的应用程序,我打算将它放在云端,我也使用ADO.NET Entity Framework来构建我的DAL,所以听起来像ADO.NET Data Services是我可以选择的。

One cool thing I found out about ADO.Net Data Services and the cloud is that the underlying DataContext that acts as the provider to your data source can be easily configured to point your resource in the cloud, OR, an on premise database. 我发现有关ADO.Net数据服务和云的一个很酷的事情是,作为数据源提供者的底层DataContext可以轻松配置为将您的资源指向云,OR,一个内部部署数据库。 This allows you to switch your DataContext without changing any code!!! 这允许您在不更改任何代码的情况下切换DataContext! (I was impressed by that if you couldn't tell) (如果你不知道的话,我印象深刻)

Could you maybe say more on this point regarding how ADO.NET Data Service + EF would work in the cloud? 您是否可以就ADO.NET数据服务+ EF如何在云中运行这一点进行更多说明?

ADO.Net数据服务和WCF Rest服务之间的主要区别之一是REST服务重量轻,您可以通过编写单独的方法/函数来自定义获取的内容,而ADO.Net数据服务更像是转储,您可以获得所有内容...对于Web和RIA应用程序,在我看来,WCF Rest服务是最佳和优化的选择......

WCF数据服务(以前称为ADO.NET数据服务), http://msdn.microsoft.com/en-us/data/aa937697.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM