You need to create an equality comparer and use it in the Union or Distinct : Public Class MyComparer Implements IEqualityComparer(Of ICustomer) Public Overloads Function Equals(ByVal x As ICustomer, ByVal y As ICustomer) _ As Boolean Implements _ System.Collections.Generic. IEqualityComparer(Of ICustomer). Equals Return ((x.Id = y.
Id) AndAlso (x. Title = y. Title)) End Function Public Overloads Function GetHashCode(ByVal obj As ICustomer) _ As Integer Implements _ System.Collections.Generic.
IEqualityComparer(Of ICustomer). GetHashCode Return Me.GetHashCode() End Function End Class Usage example: Dim allMatch = shortNameMatch. Union(custNameMatch).
Distinct(New MyComparer()) Dim allMatch = shortNameMatch. Union(custNameMatch, New MyComparer()).
You need to create an equality comparer and use it in the Union or Distinct: Public Class MyComparer Implements IEqualityComparer(Of ICustomer) Public Overloads Function Equals(ByVal x As ICustomer, ByVal y As ICustomer) _ As Boolean Implements _ System.Collections.Generic. IEqualityComparer(Of ICustomer). Equals Return ((x.Id = y.
Id) AndAlso (x. Title = y. Title)) End Function Public Overloads Function GetHashCode(ByVal obj As ICustomer) _ As Integer Implements _ System.Collections.Generic.
IEqualityComparer(Of ICustomer). GetHashCode Return Me.GetHashCode() End Function End Class Usage example: Dim allMatch = shortNameMatch. Union(custNameMatch).
Distinct(New MyComparer()) Dim allMatch = shortNameMatch. Union(custNameMatch, New MyComparer()).
That rocked. Thought I might need something like that, but couldn't find it anywhere. – Anthony Potts May 19 '10 at 22:00 Or use morelinq's DistinctBy: code.google.Com/p/morelinq/wiki/OperatorsOverview – TrueWill Dec 2 '10 at 23:31.
Union will remove duplicates. If you need to apply a condition other than reference equality, pass an IEqualityComparer into Union.
When I take these two result sets and then union them together (which I have read several places should remove distinct values) I get duplicates. Thinking that all I need to do is then call the .Distinct() method on this, I also still get duplicates. Do I need to implement some compare functionality in my customer object?
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.