实体框架多对多选择
该模型包含 2 个具有多对多关系的实体:目录项和关键字。
假设定义了 2 个变量:
ObjectQuery<Keyword> KW;
ObjectQuery<CatalogueItem> CI;
KW 包含一些用于选择一组关键字的查询。我需要获取CI来选择至少具有KW中的一个关键字的所有CatalogueItems。
重要的是:不应预先计算或枚举任何内容。关键字枚举需要花费大量时间,但 UI 是基于实时 CatalogueItems 显示的。完美的事情是让CI准备好执行。
The model contains 2 entities with many-to-many relationship: CatalogueItems and Keywords.
Assume that 2 variables are defined:
ObjectQuery<Keyword> KW;
ObjectQuery<CatalogueItem> CI;
KW contains some query for selecting a set of keywords. I need to get CI that selects all CatalogueItems that have at least one Keyword from KW.
An important thing: nothing should be pre-computed or enumerated. Keywords enumeration takes a lot of time, but UI is based on live CatalogueItems displaying. A perfect thing would be to get CI ready for execution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
类似的事情?请检查语法。
Something like that? Please check the syntax.
像这样的东西:
编辑:
这样就不会每次都计算 KW,请尝试这样做:
否则,我需要查看 KW 中的查询和整个数据库才能知道如何优化查询。
另一种选择是简单地编写一个存储过程并将其与实体框架进行映射。
Something like this:
EDIT:
So that KW isn't calculated every time, try doing this:
Otherwise, I'll need to see the query in KW and your whole database to be able to know how to optimize the query.
Another option would be to simply write a Stored Procedure and map it with Entity Framework.