本文介绍了OData的与ServiceStack?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我刚刚看到 ServiceStack 和我正在考虑建立一个服务吧。I just saw ServiceStack and I am considering building a service with it.是否有可能担任的OData与服务栈饲料,这样我就能揭露IQueryable的,并从客户端查询它?Is it possible to serve OData feeds with service stack so that I'd be able to expose IQueryable and query it from the client?推荐答案 ServiceStack现在又增加自动查询的是我们要实现数据驱动服务,避免的方法由OData的促进了陷阱和反模式。EditServiceStack has now added Auto Query which is our approach to enabling data-driven services that avoids the pitfalls and anti-patterns promoted by OData.将ServiceStack支持的OData。 Will ServiceStack support OData.没有。不能直接反正。如果有人认为,在任何OData的价值,他们可以自由地添加必要的功能作为一个可选插件 - 但它永远不会内置于ServiceStack芯。Not directly anyway. If anyone sees any value in OData they are free to add the necessary functionality as an optional Plugin - but it will never be built into the ServiceStack core.的OData是一个贫穷的适合ServiceStack谁href=\"http://www.infoq.com/articles/interview-servicestack\"> 与魔力行为我们认为这是一个 的经典例子:OData is a poor fit for ServiceStack who vehemently opposes heavy abstractions and "magic behavior" which we view as a classic example of:您节省每一分钟,当你看中的框架确实不可思议的事情 帮你出费用未来你10分钟调试。不值得。 Every minute you save when your fancy framework does magical things to help you out costs future-you ten minutes of debugging. Not worth it.我们不认为依靠从暗箱斑点魔行为永远持续了时间的考验。从历史上看,每当我们使用这个(如 ADO.NET数据集 ASP.NET动态数据)我们已经迅速碰上这是在功能的不断发展,以支持新的开发实践,模式和他们的目的不是技术,这些框架的固有灵活的限制,支持,导致被赞成新框架pcated快速去$ p $的能够。这是一个重新写周期,我们不希望促进。We don't think relying on magic behavior from black-box blobs ever lasts the test of time. Historically whenever we've used this (e.g. ADO.NET DataSets, ASP.NET Dynamic Data) we've quickly run into the inherent in-flexible limitations of these frameworks which are in-capable of evolving to support new developer practices, paradigms and technologies they weren't designed to support, resulting in being quickly deprecated in favor of newer frameworks that can. This is a re-write cycle we don't wish to promote.的OData也促进了反模式在这里你的暴露内部实现细节为您服务您的暗示服务合同紧密耦合到底层的RDBMS表给你了缓冲能力有限的控制,再保理或将来的服务版本的能力。OData also promotes the anti-pattern where you're exposing internal implementation details of your service tightly coupling your implicit service contract to the underlying RDBMS tables giving you limited control over the cachability, re-factoring or version-ability of your services in future.这是类似于交给你的数据库连接字符串,其中只要你在生产客户绑定到它,表的结构变得冻结抑制演变现有的数据库表,因为它有可能打破现有客户的能力。 ServiceStack的建议是让您的客户端绑定到你可以自由地重新因素的实现一个定义良好的服务层。This is akin to handing your db connection string where as soon as you have clients in production binding to it, the structure of the tables become frozen inhibiting the ability to evolve your existing DB tables since it could potentially break existing clients. ServiceStack's recommendation is having your clients binded to a well defined service layer that you are free to re-factor the implementation of.要总结的OData确实提供了丰富的功能,但我个人不建议其内部网之外使用,你不控制,并可以部署客户端和服务器。To summarize OData does indeed provide rich functionality but I personally don't recommend its use outside the intranet where you don't control and can deploy both Client and Server.的WebAPI是通过返回的OData的隐性支持的最佳选项的IQueryable&LT; T&GT; 接口WebApi is the best option with implicit support for oData via returning the IQueryable<T> interface.一个网页/远程服务(和SOA尤其是)的主要好处是,它提供了你希望公开任何功能的技术无关,可互操作的门面。虽然的OData 是一个开放的标准,技术本身已基本上只已通过微软的.NET相关的举措的。One of the major benefits of web/remote services (and SOA in particular) is that it provides a technology-agnostic and interoperable facade over any functionality you wish to expose. Although OData is an open standard, the technology itself has essentially only been adopted by Microsoft and .NET related initiatives.的OData 本身已经发现是慢(这是禁忌我们的核心目标)和在实施缺乏控制使得它很难简洁地实现性能提升技术,如高速缓存了它。OData itself has found to be slow (which is contra to our core objectives) and the lack of control over the implementation makes it difficult to cleanly implement performance enhancing techniques like caching over it.我给一个具体的例子,为什么的OData是一个坏主意的意见,在的 IQueryable的是紧耦合后我将在这里重复了preservation:I've given a concrete example in the comments of why oData is a bad idea, at the end of the IQueryable is Tight Coupling post which I'll repeat here for preservation:的Web服务接口的整体思路是揭露一个 技术不可知的可互操作的API到外面的世界。 The whole idea of web service interfaces is to expose a technology-agnostic interoperable API to the outside world.揭露一个IQueryable / OData的端点有效地将你的 使用OData的无限服务,你不会能够可行性的 确定什么查询空间现有的客户端绑定到,即什么 现有查询/表/视图/你需要冻结性能/支 下去。暴露在任何实现时这是一个问题 您的API的表面积,因为它限制了你添加你自己的能力 就可以了,例如自定义逻辑授权,缓存,监控, 限速等,而且由于OData的实在是太慢了,你会打 性能/缩放初与它的问题。过度缺乏控制 端点,意味着你切实为重写标题: https://coldie.net/?tag=servicestackExposing an IQueryable/OData endpoint effectively couples your services to using OData indefinitely as you wont be able to feasibly determine what 'query space' existing clients are binded to, i.e. what existing queries/tables/views/properties you need to freeze/support indefinitely. This is an issue when exposing any implementation at the surface area of your API, as it limits your ability to add your own custom logic on it, e.g. Authorization, Caching, Monitoring, Rate-Limiting, etc. And because OData is really slow, you'll hit performance/scaling problems with it early. The lack of control over the endpoint, means you're effectively heading for a rewrite: https://coldie.net/?tag=servicestack让我们看看如何可行的是将动销的OData的供应商 实现通过查看从Netflix的OData的现有查询 API:Lets see how feasible is would be to move off an oData provider implementation by looking at an existing query from Netflix's OData api: http://odata.netflix.com/Catalog/Titles?$filter=Type%20eq%20'Movie'%20and%20(Rating%20eq%20'G'%20or%20Rating%20eq%20'PG-13')http://odata.netflix.com/Catalog/Titles?$filter=Type%20eq%20'Movie'%20and%20(Rating%20eq%20'G'%20or%20Rating%20eq%20'PG-13')本服务有效地现在连接到表/视图称为 图书与一列名为类型。This service is effectively now coupled to a Table/View called 'Titles' with a column called 'Type'.和它将如何,如果你没有使用OData的自然地写:And how it would be naturally written if you weren't using OData: http://api.netflix.com/movies?ratings=G,PG-13现在,如果因任何原因需要更换的实施 现有的服务(例如一个更好的技术平台已经出现, 它运行速度太慢,你需要在移动这个数据集到 NoSQL的/全TextIndexing支持SLN)多大的努力将它带到 更换的OData IMPL(这是有效地绑定到一个RDBMS架构 和OData的二进制implement执行),以更直观的IMPL无关查询 下面?这不是不可能的,但因为它是比登天还难 实施一种新技术的OData的API时,该重写+破 现有的客户会倾向于是preferred选项。Now if for whatever reason you need to replace the implementation of the existing service (e.g. a better technology platform has emerged, it runs too slow and you need to move this dataset over to a NoSQL/Full-TextIndexing-backed sln) how much effort would it take to replace the OData impl (which is effectively binded to an RDBMS schema and OData binary impl) to the more intuitive impl-agnostic query below? It's not impossible, but as it's prohibitively difficult to implement an OData API for a new technology, that rewriting + breaking existing clients would tend to be the preferred option.放生内部实现决定了面向外部URL 结构是一种肯定的方式来打破现有的客户端,当事情需要 更改。这就是为什么你应该揭露背后酷的URI您的服务, 即逻辑永久的URL(由实施畅通) 不改变,因为你通常不希望限制 技术选择你的服务。Letting internal implementations dictate the external facing url structure is a sure way to break existing clients when things need to change. This is why you should expose your services behind Cool URIs, i.e. logical permanent urls (that are unimpeded by implementation) that do not change, as you generally don't want to limit the technology choices of your services.如果你想实现即席这可能是一个不错的选择的探索 它的服务',但它不是我所希望外部客户端 在生产系统中绑定到。如果我只是要限制其 用我的本地Intranet它有超过只是给哪些优势 出一个只读连接字符串?这将允许他人使用与 他们最喜欢的Sql资源管理器,报表或者说任何一种其他工具 SQL。It might be a good option if you want to deliver adhoc 'exploratory services' on it, but it's not something I'd ever want external clients binded to in a production system. And if I'm only going to limit its use to my local intranet what advantages does it have over just giving out a read-only connection string? which will allow others use with their favourite Sql Explorer, Reporting or any other tools that speaks SQL. Netflix公司刚刚退休的OData的目录,有效的2013年4月8日。UpdateNetflix has just retired its OData catalog, effective on April 8, 2013.在增加了新的答案,为什么我们推荐使用干净的,明确的污点DTO的与定义任何远程服务,在远程服务的最佳实践,使用OData的不提倡。Added new answer on why we recommend using clean, well-defined untainted DTO's for defining any remote services with, which is a remote services best-practices that using OData doesn't promote.为什么通用基于API,如OData的更为脆弱,复杂和难度比使用好文章相当于基于意图的API 的。 这篇关于OData的与ServiceStack?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-12 04:08