想象四个列表,都至少有这个 Id 字符串属性,但可能还有其他属性:
public class A //or B, C, D
{
public string Id { get; set; }
//..other properties
}
//so:
List<A> a1 = new List<A>();
List<B> a2 = new List<B>();
List<C> a3 = new List<C>();
List<D> a4 = new List<D>();
我想在 a1 中选择所有 DISTINCT id,结合 a2、a3 和 a4
我认为 LINQ 语法会是理想的,但是如何将这些与单个字符串属性结合到 IEnumerable 结果中,例如具有 A 类定义的东西。