是否可以使用 system.data.services.client 进行动态查询
设置客户端的正常方法是通过使用 VS UI 或 datasvcutil 读取 odata 元数据来生成模型。有没有办法不用这一步就可以做到。
为什么?想象一下尝试制作一个通用的 odata UI(这不是我正在做的事情,但存在相同的需求)。我知道我可以执行原始 HTTP/XML 等,但这似乎是一项繁重的工作;寻找中途之家。
The normal way to setup a client is to generate a model by reading the odata metadata using VS UI or datasvcutil. Is there a way to do it without that step.
Why? Imagine trying to make a general purpose odata UI (thats not what I am doing but the same need would exist). I know that I can do raw HTTP/XML etc but that seems like a lot of heavy lifting; looking for a halfway house.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
客户端依赖 CLR 类型来描述要使用的实体的形状。因此,如果您需要一个通用客户端(它对它将要使用的实体的形状一无所知),那么您需要为每个查询动态生成这些类型(在执行查询之前,这可能很棘手)。简而言之,客户端并不是为支持这种情况而构建的。
您可以看一下 OData Explorer,它是一个 Silverlight 应用程序并实现了通用客户端。 (由于上述限制,它不使用 WCF 数据服务客户端)。这是此页面上的示例之一: http://www.odata.org/developers/odata- sdk。您可以在这里尝试一下:http://www.silverlight.net/content/samples/odataexplorer /
The client relies on CLR types to describe the shape of entities to consume. So if you need a general purpose client (which knows nothing about the shape of entities it's going to consume), then you would need to dynamically generate these types for each query (before you execute the query, which might be tricky). In short, the client is not built to support such scenario.
You can take a look at OData Explorer, which is a Silverlight application and implements the general purpose client. (it does not use the WCF Data Services client due to the above restrictions). It's one of the samples on this page: http://www.odata.org/developers/odata-sdk. You can try it ou here: http://www.silverlight.net/content/samples/odataexplorer/