结合Linq加入

时间:2018-02-01 19:27:26

标签: c# linq

我如何将它们组合在一起? job.Result?.Name需要等于Scene7ImageSet1或Scene7ImageSet2。

(from job in jobs
      join product in products on job.Result?.Name equals product?.Scene7ImageSet1
 select product.MediaSet = job.Result).ToList();

(from job in jobs
      join product in products on job.Result?.Name equals product?.Scene7ImageSet1
 select product.MediaSet = job.Result).ToList();

1 个答案:

答案 0 :(得分:0)

您可以将||运算符应用于where子句。

(job.Result?.Name==product?.Scene7ImageSet1 || job.Result?.Name==product?.Scene7ImageSet1)

查询看起来像;

 (from job in jobs
 from product in products
 where (job.Result?.Name==product?.Scene7ImageSet1 || job.Result?.Name==product?.Scene7ImageSet1)
 select new{...}).ToList();