I’ve got 2 object arrays that Im getting from the DB, some overlap, so I have to make a distinct func.
I tried to make a lambda expression , but I still got an overlapped objects.
this is my code:
ArtObject[] pinui = new ArtObject[root.Count - 1];
ArtObject[] c1= new ArtObject[root2.Count - 1];
pinui = getArticlesArray(root2, pinui);
c1= getArticlesArray(root, c1);
art = new ArtObject[c1.Count()+pinui.Count()];
pinui.CopyTo(art, 0);
c1.CopyTo(art, pinui.Count());
art = art.Distinct().OrderByDescending(a => a.dateTosort).ToArray();
I guess something wrong with my last line, art = art.Distinct().OrderByDescending(a => a.dateTosort).ToArray(); .. I wonder what and how can I get only the distinct objects..?
If you do distinct on one of fields, you can use
GroupBythen getFirst: