I am comparing to list using intersect as follows:
(Using POCO Car as an example)
IEnumerable<Car> updatedCars = CarsList.Intersect(dbCarsList, carsComperator);
I defined carsComperator as follows
public bool Equals(Car x, Car y)
{
if (object.ReferenceEquals(x, y)) return true;
if (x == null || y == null) return false;
return (x.Id == y.Id);
}
public int GetHashCode(Car car)
{
return car.Id.GetHashCode(); // Id is Guid
}
But when Intersect command runs it brings nothing.
I assume that the program does not pass throgh my comparator since there is no stopping at my breakpoints there.
Any idea of what am I doing wrong?
Try iterating through the result list. If Intersect uses yield return mechanism, it will initiate comparison only when resulting IEnumerable is iterated through.