Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8207317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:57:38+00:00 2026-06-07T08:57:38+00:00

I read in a few places that LINQ equals (in join syntax) calls IEquatable

  • 0

I read in a few places that LINQ equals (in join syntax) calls IEquatable for the type it’s comparing, but I don’t see it happening in my join:

List<ILData> list1 = new List<ILData> { /* Initialized with items */ };
List<ILData> list2 = new List<ILData> { /* Initialized with items */ };

var joinItems = (
    from d1 in list1
        join d2 in list2
        on d1 equals d2
    where d1.SomeValue == "7"
    select d1).Distinct().ToList<ILData>();

Assuming I provided an interface definition satisfying:

ILData : IEquatable<ILData>

requirements, why wouldn’t I be seeing ILData::Equals get called in this case?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T08:57:39+00:00Added an answer on June 7, 2026 at 8:57 am

    It uses EqualityComparer<T>.Default. Since your type implements IEquatable<T>, the actual comparer used will be an internal class called System.Collections.Generic.GenericEqualityComparer<T>, which will delegate GetHashCode and Equals requests to your object.GetHashCodemethod and IEquatable<ILData>.Equals methods respectively (except for null references, where it returns a zero hash-code / does a reference-equality check without calling your methods).

    There are a number of reasons that could explain your Equals method not being hit:

    1. There’s an empty sequence at play here.
    2. Your breakpoint is on object.Equals rather than IEquatable<ILData>.Equals
    3. The second sequence only contains null references (this is checked by the framework comparer, so it won’t enter yours).
    4. There are no hash matches (from GetHashCode), so the join operation never needs to do a full equality check. One reason this might be happening is that you forgot to override this method and are therefore stuck with the default one from object (which is designed for reference equality and will be inconsistent with your definition of equality).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've read in a few places now that the maximum instance size for a
I've read at a few places that I should not be using Activities as
I have read in a few places that you can compile Ninject to work
I've read in a few places that PhoneApp (com.android.phone.PhoneApp.java), is a persistent process which
I've read in a few places that the log4net threadContext isn't safe to use
I've read on few places already, that it's possible to combine XNA and WPF.
I read in a few places that MVC requires Windows Server 2008 for full
I read at a few places (in the doc and in this blog post
I read few articles on jsplumb , but cannot yet understand the usage. I
I have read few articles about table partioning but still I am bit confused

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.