If you look at the source code of Rx, you will find that different ones use a hashset and store the values ββthere. Your assumption that the element is simply located is incorrect.
If your order objects are heavy, you can use keyselector, and RX just saves that value in a hashset.
.Distinct(o => Tuple.Create(o.id, o.Date), distinctPerDayComparer);
then you need to change the PerDayComparer parameter
public class DistinctPerDayComparer : IEqualityComparer<Tuple<int, DateTime>> { public bool Equals(Tuple<int, DateTime> o1, Tuple<int, DateTime> o2) { if(o1.Item1 != o2.Item1) return false; bool isSameDay = o1.Item2.Day == o2.Item2.Day; return isSameDay; } public int GetHashCode(Tuple<int, DateTime> o) { return o.Item1.GetHashCode(); } }
did not test the code, but should be the starting one. Now save the Tuples until the sequence is complete, and not the Order objects.
Otherwise, you can use the Window function to group them and clear them according to a schedule, but then it is not really distinguishable for the entire observed sequence.
source share