为 Enumerable.GroupJoin 使用额外的 condition/parameter
Use an additional condition/parameter for Enumerable.GroupJoin
我在 MSDN 查看了 GroupJoin 方法的文档,但我看不出如何在多个 属性 上创建连接。下面是我当前代码的示例。
var test = _MasterData.LinqCustomerGroup.GroupJoin(_MasterData.LinqDisposallistDisposalArticles,
c => c.Guid,
d => d.CustomerGroup,
(c, ds) => new { c, ds = ds })
.SelectMany(z => z.ds.DefaultIfEmpty(), (c, d) => new { CustomerGroupID = c.c.CustomerGroupID, Description = c.c.Description, Disposallist = d.Disposallist }));
我想对附加参数执行连接。 d 里面有一个名为 Article 的属性。我希望该函数仅连接具有 Article == "value".
的元素
听起来您不想"join on an additional condition",但过滤 出LinqDisposallistDisposalArticles
中具有Article
的所有元素不同于 "value"
.
如果这是正确的,只需在加入之前对该序列使用 Where
:
var test = _MasterData.LinqCustomerGroup.GroupJoin(
// filter inner sequence
_MasterData.LinqDisposallistDisposalArticles.Where(d => d.Article == "value"),
c => c.Guid,
d => d.CustomerGroup,
(c, ds) => new { c, ds = ds })
.SelectMany(....);
我在 MSDN 查看了 GroupJoin 方法的文档,但我看不出如何在多个 属性 上创建连接。下面是我当前代码的示例。
var test = _MasterData.LinqCustomerGroup.GroupJoin(_MasterData.LinqDisposallistDisposalArticles,
c => c.Guid,
d => d.CustomerGroup,
(c, ds) => new { c, ds = ds })
.SelectMany(z => z.ds.DefaultIfEmpty(), (c, d) => new { CustomerGroupID = c.c.CustomerGroupID, Description = c.c.Description, Disposallist = d.Disposallist }));
我想对附加参数执行连接。 d 里面有一个名为 Article 的属性。我希望该函数仅连接具有 Article == "value".
的元素听起来您不想"join on an additional condition",但过滤 出LinqDisposallistDisposalArticles
中具有Article
的所有元素不同于 "value"
.
如果这是正确的,只需在加入之前对该序列使用 Where
:
var test = _MasterData.LinqCustomerGroup.GroupJoin(
// filter inner sequence
_MasterData.LinqDisposallistDisposalArticles.Where(d => d.Article == "value"),
c => c.Guid,
d => d.CustomerGroup,
(c, ds) => new { c, ds = ds })
.SelectMany(....);