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

  • Home
  • SEARCH
  • 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 7974759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:28:06+00:00 2026-06-04T08:28:06+00:00

I’m trying to use the Entity Framework to create a complex query and get

  • 0

I’m trying to use the Entity Framework to create a complex query and get stuck in the joins. After browsing some of the documentations, I cannot seem to find the correct solution, so maybe someone here can help.

I have a data structure where a family has several family members, each of which can have more than one entry in the income table (on different registration dates) and can have more than one entry in the healthconditions table.

What I would like to obtain is the result of the following query

select [some stuff] from FamilyMember fm
left join FamilyMemberIncome fmi on fm.id=fmi.familymemberid
left join Education e on e.id=fmi.educationid
left join FamilyMemberHealthCondition fmhc on fm.id=fmhc.familymemberid
left join HealthCondition hc on fmhc.healthconditionid=hc.id

This will obviously return multiple results for a single family member, but that’s ok.
My attempt in code started like this (but is incorrect: “id is not a member of anonymous type”)

Dim familyMembers As IQueryable = database.FamilyMember _
            .Join( _
                database.FamilyMemberIncome, _
                Function(fm) fm.id, _
                Function(fmi) fmi.familymemberid, _
                Function(fm, fmi) New With { _
                    .fmEducation = fmi.Education, _
                    .fmIncome = fmi.averagemonthlyincome, _
                    .fmProfession = fmi.profession _
                }
            ) _
            .Join( _
                database.FamilyMemberHealthCondition, _
                Function(fm) fm.id, _
                Function(fmhc) fmhc.familymemberid, _
                Function(fm, fmhc) New With { _
                    .fmHealthCondition = fmhc.HealthCondition
                }
            )

Can someone show me (or point me to an article explaining) the right way of doing this?

  • 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-04T08:28:08+00:00Added an answer on June 4, 2026 at 8:28 am

    OK, since your lonely at the top :)… Maybe you figured it out yourself in the mean time, but the syntax would be something like:

    From fm in FamilyMember
    Join fmi In FamilyMemberIncome On fm.id Equals fmi.familymemberid
    Join e In Education On fmi.educationid Equals e.id
    Join fmhc In FamilyMemberHealthCondition On fm.id Equals fmhc.familymemberid
    Join hc In HealthCondition On fmhc.healthconditionid Equals hc.id
    Select New With { .Name = fm.Name, .Income = fmi.Income, ...more... }
    

    (leaving out the database. part for brevity)

    This is so called comprehensive syntax. Personally I prefer fluent or chained syntax (FamilyMember.Select(...)), except with joins. Especially a number of joins in a row make it very hard to handle the result selector functions and quickly makes code messy.

    The best way to master linq, has been my experience, is doing it. When linq was introduced I looked into the MSDN documentation of IEnumerable and did some exercises with each and every extension method. This has proven very useful.

    Understanding the difference between Join and GroupJoin is especially useful in Linq-to-Sql or EF. The former translates to an inner join, the latter to an outer join.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported

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.