如果我想要 OData + 是否需要创建自定义数据提供程序? EF +我自己的合同?
我正在为我的公司使用实体框架 (EF) 创建 OData(WCF 数据服务)端点。
我们已经意识到标准 OData + EF 将我们与数据库耦合得太紧密了]1。因此,我希望在 EF 和 OData 之间添加另一层。
所以我的问题是:我需要制作一个 自定义数据服务提供商 或者有什么方法可以连接 OData 反射提供者到 EF?我读过有关反射提供程序的内容,它似乎只适用于内存中的东西。我不知道如何将其连接到 EF 加载数据的方式。
注意:我的 OData 服务是只读的。我不需要它们可更新。
I am making an OData (WCF Data Service) endpoint using Entity Framework (EF) for my company.
We have realized that standard OData + EF couples us too closely to the database]1. So I am looking to add another layer between EF and OData.
So my question is: Do I need to make a Custom Data Service Provider or is there a way I can wire up the OData Reflection Provider to EF? I have read about the Reflection Provider and it seems to work with in-memory stuff only. I don't know how to wire that up to EF's way of loading data.
Note: My OData services are Read Only. I don't need them to be updateable.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我了解您的问题反射提供程序应该满足您的所有要求。您只需要创建一些类,该类将使用自定义对象的
IQueryable
公开属性。反射提供程序不仅仅适用于内存内容 - 它只需要一个类来通过反射进行探索,但该类的实现取决于您。 Linq-to-Sql 上下文也通过反射提供程序公开,它们绝对不仅仅是内存中的东西。您将遇到的问题是将对自定义对象的查询转换为对实体的查询,因为这无法在本机进行翻译。
As I understand your problem Reflection provider should meet all your requirements. You just need to make some class which will expose properties with
IQueryable<>
of your custom objects. Reflection provider doesn't work with memory stuff only - it just needs a class to explore with reflection but implementation of that class is up to you. Linq-to-Sql contexts are also exposed through reflection provider and they are definitely not only in-memory stuff.The problem which you will have is translating queries to your custom objects into queries to your entities because that cannot be translated natively.