【发布时间】:2013-06-17 09:42:42
【问题描述】:
下面的查询在 serverID 上连接两个表,并返回 ServerID 和属于它们的组件,如下所示
LINQ
var header = from a in this.db.Servers
where a.ServerID.Contains(match)
join b in this.db.Components
on a.ServerID equals b.ServerID into g
select new
{
a.ServerID,
Comp = g.Select(x => x.Name),
};
输出
Server X
common component
component 1x
component 2x
component 3x
Server Y
common component
component 1y
component 2y
component 3y
Server Z
common component
component 1z
component 2z
component 3z
如何检索上述结果,删除记录公共组件?这可以在 SQL 中使用 不等于来实现。上面的代码如何实现?
【问题讨论】:
-
所以你只想从结果集中排除
common component? -
@demo_user 检查Jon Skeet's answer,你一定会明白的。