Taking union of two lists based on column

后端 未结 3 868
渐次进展
渐次进展 2021-01-27 02:41

I am taking a union of two lists using Linq to Sql. Using List1 and List2:

 var tr = List1.Union(List2).ToList();

Union works fine, but the pro

3条回答
  •  甜味超标
    2021-01-27 03:14

    try somthing this

    var List3 = List1.Join(
    List2, 
    l1 => l1.Id,
    l2 => l2.Id,
    (l1, l2) => new Model
    {
       Id = l1.Id,
       Val1 = l1.Val1 or other,
       Val2 = l2.Val2  or other
    });
    

    for more details you can show your model

提交回复
热议问题