I have a class
class ShipmentsComparer : IEqualityComparer<Routes>
{
public bool Equals(Routes route1, Routes route2) =>
route1.DockCode == route2.DockCode
&& route1.CarrierArrival == route2.CarrierArrival;
public int GetHashCode(Routes obj) =>
obj.DockCode.GetHashCode() ^ (obj.CarrierArrival.GetHashCode() * 13);
}
and a IEnumerable
public IEnumerable <Shipments> Shipments
{
get
{
Debug.Print("Initiated");
foreach (var item in Loads)
{
if (item.ShipTo.Contains(" "))
{
foreach (var item2 in Routes.Where(d => d.DockCode == item.ShipTo.Substring(0, item.ShipTo.IndexOf(" ")) && d.CarrierDeparture.TimeOfDay == item.ShipTime.TimeOfDay).Distinct(new ShipmentsComparer()))
{
yield return new Shipments() { Arrival = item2.CarrierArrival, Departure = item2.CarrierDeparture, Issuer = item.Customer, Destination = item.ShipTo, LoadType = item.LoadType };
}
}
}
}
}
to remove duplicate values but I am still getting duplicates in my item source shown here:
How would I get this to only show one of each carrier arrival time?
