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 7569995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:18:23+00:00 2026-05-30T15:18:23+00:00

I know there are several questions regarding this topic. However; I cannot find one

  • 0

I know there are several questions regarding this topic. However; I cannot find one that is directly related to my problem.

I have 3tables in a DB and the PK’s from those 3 tables form a composite PK in a XRef table.

I need to be able to select Distinct items based on 2 of the keys just for display on a report.

    public IEnumerable<AssemblyPrograms> GetProgramAssemblies()
    {
        var assembliesList = (from c in eModel.Assemblies.ToList()
                             join d in eModel.Programs_X_Assemblies_X_Builds
                             on c.AssemblyID equals d.AssemblyID
                             join p in eModel.Programs
                             on d.ProgramID equals p.ProgramID
                             join a in eModel.AssemblyTypes
                             on c.AssemblyTypeID equals a.AssemblyTypeID

                             select new AssemblyPrograms
                             {
                                 AssemblyID = c.AssemblyID
                                 ,ProgramID = d.ProgramID
                                 ,AssemblyName = c.AssemblyName
                                 ,AssemblyPrefixName = c.AssemblyPrefixName
                                 ,ProgramName = p.ProgramName
                                 ,AssemblyTypeName = a.AssemblyTypeName
                                 ,AssemblyTypeID = a.AssemblyTypeID
                             });

        return assembliesList;
    }

This is my query and what I need to pull out of the tables

In my XRef table I have AssemblyID, ProgramID and BuildID as my composite PK.

There can be a many-many relationship from AssemblyID to ProgramID. The BuildID is the key that separates them.

I need to pull Distinct AssemblyID to ProgramID relationships for my report, the BuildID can be ignored.

I have tried .Distinct() in my query and a few other things to no avail.

I would appreciate any help anyone could give me.

Thanks

  • 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-05-30T15:18:24+00:00Added an answer on May 30, 2026 at 3:18 pm

    How about a Distinct overload that accepts a custom equality comparer? Something like this:

    class AssemblyComparer : EqualityComparer<AssemblyPrograms> {
        public override bool Equals(AssemblyPrograms x, AssemblyPrograms y) {
            return x.ProgramID == y.ProgramID && x.AssemblyID == y.AssemblyID;
        }
    
        public override int GetHashCode(AssemblyPrograms obj) {
            return obj.ProgramID.GetHashCode() ^ obj.AssemblyID.GetHashCode();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there have been several questions in the past regarding things that compile
I know there are several similar questions out there such as this one. I
I know there are several plugins that do asynchronous processing. Which one is the
I know there are several threads and posts regarding this issue in the internet
I know there have been several questions regarding the mousewheel and scrolling; I'm not
I know there are several questions named like this, but they don't seem to
I know there are several questions like this on here already, but I can't
I know it is easy to recommend several cross platform libraries. However, are there
I know there are several questions asking the same question Why should I use
I have several questions about the Android in-app billing, as I cannot find what

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.