我可以为此使用实体框架吗?
我正在开发一个应用程序,我想使用 ODATA 向外部世界公开。让我首先向您介绍该应用程序。
在该应用程序中,我需要创建一个库,允许用户对数据库执行 CRUD 操作。为此客户端提供了 XSD ,我们需要从中生成类。使用这些类和客户端提供的数据服务提供商用户可以执行 CRUD 操作。
该应用程序已准备就绪,现在我想使用 ODATA 公开它。以下是我将此库公开为 ODATA 的发现,
- 我需要使用自定义/反射提供程序,因为我无法使用实体框架,因为我无权访问数据。
但将来 XSD 将会改变。因此,每当发生这种情况时,我都需要更改元数据。我可以以这样的方式处理它,即在不更改代码的情况下始终公开最新的元数据吗?
我应该继续使用反射/自定义提供程序吗?
谢谢,
拉姆
I am working on a application which I want to expose to external world using ODATA. Let me first give you idea of that application.
In that application I need to create a library that will allow the users to perform CRUD operations on the database. For this client has provided XSD , from which we need to generate the classes. Using these classes and client provided data service provider user can perform the CRUD operations.
This application is ready and now I want to expose it using ODATA. Here are my findings w.r.t. exposing this library as ODATA
- I need to either use Custom/ Reflection provider as I cannot use Entity Framework because I do not have access to data.
But In future the XSD will change. So I need to change the metadata whenever this happens. Can I handle it such a way that latest metaddata will always be exposed without changing my code?
Shall I go ahead with reflection / custom provider?
Thanks,
Ram
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您绝对可以更改 XSD 更改时返回的 OData 的形状。然而,这有一个严重的问题。大多数客户端将根据添加服务引用时出现的 SSDL 生成客户端类。。结果,客户端将失败,因为对象模型将与新的数据形状不匹配。
当架构发生更改时,您最好创建一个新版本的服务。然后,即使您需要删除以前的版本(这将导致客户端出现运行时错误)。
另一种选择是使用 WCF 向前兼容的功能。但是,我不知道它们如何与 WCF 数据服务配合使用。
埃里克
You can definitely change the shape of the OData that is returned when the XSD changes. However, there is a serious problem with this. Most clients will generate client classes based on the SSDL that was present when the service reference was added. As a result, clients will fail as the object model will not match the new shape of data.
You are much better off creating a new version of the service when the schema changes. Then, even if you need to remove the previous versions (which will cause a runtime error on the client).
The other option is to use WCF forward compatible features. However, I have no idea how they work with WCF Data Services.
Erick