Please reopen 675634 - by Jamie Collins

Status : 


Sign in
to vote
ID 778536 Comments
Status Active Workarounds
Type Bug Repros 0
Opened 2/5/2013 2:28:20 AM
Access Restriction Public


The original (675634) was closed in error. The reason given was, "we'll be investing heavily in the Entity Framework rather than LINQ to SQL". However, the problem affects LINQ to Objects (not LINQ to SQL). Your investment in Entity Framework will benefit if this problem is fixed!

Three other users (abatishchev, Anders Borum, Patrick Smacchia) have posted comments agreeing that this was closed in error. I'm sure this would have many more votes by now if voting hadn't been disabled in 2011!

Original description:

I summarize the description in a blog post:

If LINQ Set operations takes account that one of the sequence can be HashSet<T>, in such case we can expect a perf gain of x2.7.

If LINQ Set operations takes account that both sequences can be collections (hence getting straight their Count()) in such case it is preferable to use longSeq.Intersect(shortSeq) instead of shortSeq.Intersect(longSeq), to prefer computing a small Set<T> instead of a large Set<T>.
Sign in to post a comment.
Posted by Microsoft on 4/22/2013 at 10:50 AM
Thanks for reporting this issue you've encountered with .NET!

We could indeed be smarter here in the LINQ sequence operations when targeting an ISet. However, we do have to be a bit careful here with the optimizations we introdue for LINQ - we can guarantee that we'll behave correctly for our built-in collections, but if a custom ISet implementation does not implement Count as expected, such an optimization could potentially break code that is working today.

This type of optimization is something we'd like to do, but unfortunately, we won't be able to fix this in the next version of .NET.

Alex Turner
Senior Program Manager
Visual Basic and C# Compiler
Posted by Microsoft on 2/5/2013 at 9:40 PM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by Microsoft on 2/5/2013 at 2:49 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(