1
Vote

Add IEqualityComparer support for ToLookup

description

I was porting fullOuterJoin from StackOverflow (see http://stackoverflow.com/a/13503860/545680) to JavaScript using LinqJS .

Using the ToLookup implementation in LInqJS you can specify a custom CompareSelector, which enables you to provide a function that will project the key to a type which can be compared with === (triple equals). This initially worked for my first full outer join as I was joining on a MomentJS type and needed to convert it to Epoch milliseconds for comparison.

I've now run into an issue where I need a composite key (a MomentJS and a string). I'm lucky in this case as the string has a set of characters that are not permitted allowing me to generate a composite string key in an error-proof way so I can create a workaround but that is not a generic solution.

I'd love to be able to specify an IEqualityComparer<TKey> object that has hashcode and equality implementations so that I could solve this in a generic way.

comments