【发布时间】:2012-01-24 13:35:48
【问题描述】:
我有产品 (p) 和材料 (m) 的多对多关系以及 products2materials 表 (p2m) 作为多对多链接。
我需要得到
- all products that have materials assigned,
- all products with no materials assigned,
- and all materials with no products assigned.
基本上是现有事物的结合。 但是,由于这将是一个数据过滤器,我需要过滤掉与搜索条件不匹配的产品和/或材料(例如所有以“A”开头的产品等)。
如何在 LINQ-to-EF 4.1 中执行此操作?
非常感谢!
【问题讨论】:
-
此时,由于 LINQ 中的完全外连接似乎令人头疼,我正在考虑一个视图,我将在其上运行 LINQ 查询。该视图将具有必要的 JOINS,并且 LINQ 查询变得更加容易。
标签: sql entity-framework many-to-many outer-join full-outer-join