简体   繁体   English

REST API的数据提供者

[英]Data provider for REST API

My application works directly with Oracle data base, using standard ADO objects DbConnection, DbDataReader, DbDataAdapter and so on. 我的应用程序使用标准ADO对象DbConnection,DbDataReader,DbDataAdapter等直接与Oracle数据库一起工作。

Now I have a task to get the same data from REST web service (http commands: get, post, put). 现在,我有一个从REST Web服务获取相同数据的任务(http命令:get,post,put)。 In my opinion, the best way to complete this task is to create a data provider for this web service, implementing ADO objects. 我认为,完成此任务的最佳方法是为此Web服务创建一个数据提供程序,以实现ADO对象。 In my application all code works only with base ADO objects. 在我的应用程序中,所有代码仅适用于基本ADO对象。 I can provide new command text for data base commands. 我可以为数据库命令提供新的命令文本。

I don't have an experience with classes, which provide functionality to work with http in .Net Framework. 我没有使用类的经验,这些类提供在.Net Framework中使用HTTP的功能。 I don't know where to start. 我不知道从哪里开始。

What is the best way to complete this task? 完成此任务的最佳方法是什么? What types may I use from .NET Framework? 我可以从.NET Framework使用什么类型? Maybe there are some implementations of similar tasks? 也许有一些类似任务的实现?

There is something that fits perfectly your needs Odata(WCF data Service ) which will publish a REST API to access your data, Check out this article for more information Odata(WCF data Service)完全符合您的需求,它将发布一个REST API来访问您的数据,有关更多信息,请查看本文。

WCF DATA services WCF DATA服务

To realise a simple provider I've decided to use Web API 2. Ie DbConnection represents a wrapper for HttpClient , DbCommand - wrapper for HttpRequestMessage . 为了实现一个简单的提供程序,我决定使用Web DbConnection 。即DbConnection代表HttpClient的包装器, DbCommand代表HttpRequestMessage包装器。

Other ADO objects will have it's own representation based on these objects. 其他ADO对象将基于这些对象拥有自己的表示形式。

I'd also suggest to read this book Designing Evolvable Web APIs with ASP.NET 我也建议阅读本书《 使用ASP.NET设计可演化的Web API》。

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

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