通过 OData 查询的数据服务公开派生类型
我创建了一个基于 EF4 CTP5 的代码优先模型,其中包括父子关系中的两个实体,其中子实体包含多个额外字段。两种类型都源自同一个 TPH 表并使用新创建的鉴别器。现在,我需要弄清楚如何通过数据服务公开子实体集并使其可用于查询。
其用例是我们有一个包含客户端层次结构的表。每个客户都有一个父母和零个或多个孩子。父级仅包含设置客户端和计费所需的信息(姓名、地址等)。除了从父级继承的属性之外,子级(您可以将它们视为卫星分支)还包含一组附加属性,这些属性是它们所独有的。所有内容都包含在同一个表中,该表已针对纯粹的搜索性能进行了非规范化。
到目前为止,我已经按照建议的方式公开了实体集 在这篇博文中建议公开一个返回 context.Child IQueryable 集合的方法。然而,这个实体集太大(700k+ 记录),无法公开整个内容,而且我似乎无法获得标准的 oData 查询来对抗服务操作。
我的问题很多,但为了使这篇文章尽可能简洁,我将限制它们。
•首先,我想知道这是否仍然是处理此问题的最佳且唯一的方法?似乎在没有此解决方法的情况下不允许公开派生类型是功能上的一个主要差距。 •第二,如何查询这个实体集?这可能吗?是否有可能我在 EF 片段中没有正确实现某些内容? 非常感谢任何和所有的帮助或建议。
最好,提前致谢!
I have created an EF4 CTP5 based code first model that includes two entities in a parent-child relationship where the child entity contains several extra fields. Both types are derived from the same table TPH and use a newly created discriminator. Now, I need to figure out how to expose the child entityset via the data service and make it available for querying.
The use-case for this is that we have a table that contains a hierarchy of clients. Each client has a parent and zero or more children. A parent contains just the information needed to set-up the client and for billing (name, address, etc.). The children (you can think of them as sattelite branches) contain an additional set of properties that are unique to them in addition to what they inherit from the parent. All are contained in the same table that has been denormalized for pure search performance.
So far, I have exposed the entity set in the manner suggested in this blog post It suggests exposing a method that returns the context.Child IQueryable collection. However, this entity set is way too large (700k+ records) to just expose the entire thing and I cannot seem to get standard oData queries to work against the service operation.
My questions are numerous but to keep this post as concise as possible I will limit them.
•First, I want to know if this is still the best and only way to handle this? It seems like not allowing derived types to be exposed without this workaround is a major gap in functionality.
•Second, how can I query this entityset? Is this possible? Is it possible I do not have something materialized properly in the EF piece?
Any and all help or suggestions are greatly appreciated.
Best and thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论