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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:35:15+00:00 2026-05-24T23:35:15+00:00

I have a member object that has a one to many relationship with a

  • 0

I have a member object that has a one to many relationship with a phones object. i want to get a list of members that have the same name and have a phone no that also matches.

I can match the records but the phone numbers are not being included because of the join. Any ideas how i might get the list of phone numbers returned?

Code so far:

            var membersA = dc.Members.Include("Phones");
            var membersB = dc.Members.Include("Phones");

            var matchingMembers = from ma in membersA
                                  join mb in membersB
                                  on new { ma.Forename, ma.Surname } equals new { mb.Forename, mb.Surname }
                                  where ma.MemberID < mb.MemberID
                                  select new { ma, mb };

            if (SearchByPhone)
                matchingMembers = from mm in matchingMembers
                                  where mm.ma.Phones.Any(phoneA => mm.mb.Phones.Any(phoneB => phoneB.PhoneNumber == phoneA.PhoneNumber))
                                  select mm;
  • 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-24T23:35:16+00:00Added an answer on May 24, 2026 at 11:35 pm

    can’t you do something like:

    var membersA = dc.Members.Include("Phones");
    var membersB = dc.Members.Include("Phones");
    
    var matchingMembers = from ma in membersA
                          join mb in membersB
                          on new { ma.Forename, ma.Surname } equals new { mb.Forename, mb.Surname }
                          where ma.MemberID < mb.MemberID and ma.Phones.Any(pa => mb.Any.Phones(pb => pb.PhoneNumber == pa.PhoneNumber)
                          select new { Member = ma, Phones = ma.Phones };
    

    Update: It appear to be some limitation with linq-to-entities and include. The code above is updated so it should work so it selects an anonymous object. I haven’t tried it and don’t know what the SQL will look like, but it could be one solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an object that has just one member with a property of type
I have a UserControl that has a BaseClass object as a public member. Right
One of my WCF functions returns an object that has a member variable of
I have an object with several text strings as members. I want to write
I have a member function in a class that has a callback, but the
I have an ICollection that I know will only ever have one member. Currently,
I have this class that has a static member. it is also a base
I have a one-to-many relationship within my class model. Example: A single role can
I have a class that has two method in it, one calls a class
I want to read from one file that has several kinds of data-types. I

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.