Taking union of two lists based on column

后端 未结 3 867
渐次进展
渐次进展 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条回答
  •  Happy的楠姐
    2021-01-27 03:16

    You should use this Union() overload (with a custom equality comparer) , or something like this:

    list1.Concat(list2).GroupBy(x => x.DateProperty).Select(m => m.First());
    

    The first solution is certainly more efficient.

提交回复
热议问题