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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:33:02+00:00 2026-05-12T23:33:02+00:00

Is this the proper way to accomplish joining 3 ( or more ) tables

  • 0

Is this the proper way to accomplish joining 3 (or more) tables with LINQ (to SQL)? Especially the select portion. Am I on the right track to return a single record(row) of data that spans across the tables?

        public static DataTable GetCurrentEmploymentQuestionnaire(Guid employmentQuestionnaireID)
    {
        var Questionnaire = from employmentQuestionnaire in context.tblEmploymentQuestionnaires
                            join prevocService in context.tblEmploymentPrevocServices on
                                employmentQuestionnaire.PrevocServicesID equals prevocService.EmploymentPrevocID
                            join jobDevelopmetService in context.tblEmploymentJobDevelopmetServices on
                                employmentQuestionnaire.JobDevelopmentServicesID equals
                                jobDevelopmetService.JobDevelopmentServicesID
                            where employmentQuestionnaire.EmploymentQuestionnaireID == employmentQuestionnaireID
                            select
                                new
                                    {
                                        EmploymentQuestionnaireID = employmentQuestionnaire.EmploymentQuestionnaireID,
                                        PlanID = employmentQuestionnaire.PlanID,
                                        HasCommunityJob = employmentQuestionnaire.CommunityJob,
                                        HasPrevocServices = employmentQuestionnaire.PrevocServices,
                                        HasJobDevelopmentServices = employmentQuestionnaire.JobDevelopmentServices,
                                        WhoCreated = employmentQuestionnaire.InsertUser,
                                        WhenCreated = employmentQuestionnaire.InsertDate,
                                        WhoUpdated = employmentQuestionnaire.UpdateUser,
                                        WhenUpdated = employmentQuestionnaire.UpdateDate,
                                        AvgRatePay = prevocService.AvgRatePay,
                                        AvgHoursWeek = prevocService.AvgHoursWeek,
                                        PrevocGoal = prevocService.PrevocGoal,
                                        SkillsTaught = prevocService.SkillsTaught,
                                        SkillsLearned = prevocService.SkillsLearned,
                                        AnticipatedTransitionPlan = prevocService.AnticipatedTransitionPlans,
                                        AnticipatedEndDate = prevocService.AnticipatedEndDate,
                                        TypeWorkDesired = jobDevelopmetService.TypeWorkDesired,
                                        NeedEmpServices = jobDevelopmetService.NeedEmploymentServices,
                                        IsDVRProvidingServices = jobDevelopmetService.DVRProvidingServices,
                                        DVRCurrentReferralExists = jobDevelopmetService.DVRCurrentReferral
                                    };

        return Questionnaire.CopyLinqToDataTable();
    }

Database structure is as follows –>

tblEmploymentQuestionnaire

EmploymentQuestionnaireID   uniqueidentifier    Unchecked
PlanID                  int                     Unchecked
CommunityJob            bit                 Checked
PrevocServices          bit                 Checked
PrevocServicesID            uniqueidentifier    Checked
InsertUser                  varchar(50)         Checked
InsertDate                  datetime            Checked
UpdateUser                  varchar(50)         Checked
UpdateDate                  datetime            Checked
JobDevelopmentServices  bit                 Checked
JobDevelopmentServicesID    uniqueidentifier    Checked

tblEmploymentPrevocServices

EmploymentPrevocID  uniqueidentifier    Unchecked
AvgRatePay  varchar(50) Checked
AvgHoursWeek    varchar(50) Checked
SettingID   int Checked
PrevocGoal  varchar(500)    Checked
SkillsTaught    varchar(500)    Checked
SkillsLearned   varchar(500)    Checked
AnticipatedTransitionPlans  varchar(500)    Checked
AnticipatedEndDate  datetime    Checked
RatioID int Checked
rowguid uniqueidentifier    Unchecked

tblEmploymentJobDevelopmentService

JobDevelopmentServicesID    uniqueidentifier    Unchecked
TypeWorkDesired varchar(50) Checked
PreferredWorkHoursID    int Checked
NeedEmploymentServices  bit Checked
DVRProvidingServices    bit Checked
DVRCurrentReferral  bit Checked
CMOProvidingServices    bit Checked
CMONotProvidingReason   varchar(500)    Checked
PaidCoachingHoursID int Checked
PlanSegregatedToIntegrated  varchar(500)    Checked
RoleResponseJobDeveloper    varchar(500)    Checked
RoleResponseMember  varchar(500)    Checked
RoleResponseWWCTeam varchar(500)    Checked
PlanDVRToWWCFund    varchar(500)    Checked
DVRCurrentReferralStatusID  int Checked

Sorry it ended up being so long. If you are still with me, thank you and bonus appreciation points if someone can point out in the comments how I could have shortened this while still asking my question. I would appreciate it for future reference.

  • 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-12T23:33:02+00:00Added an answer on May 12, 2026 at 11:33 pm

    Assuming your relationships are well defined in the dbml, the generated classes should allow you to query like this:

    var Questionnaire = from employmentQuestionnaire in context.tblEmploymentQuestionnaires
                        where employmentQuestionnaire.EmploymentQuestionnaireID == employmentQuestionnaireID
                        select new
                               {
                                   EmploymentQuestionnaireID = employmentQuestionnaire.EmploymentQuestionnaireID,
                                   PlanID = employmentQuestionnaire.PlanID,
                                   HasCommunityJob = employmentQuestionnaire.CommunityJob,
                                   HasPrevocServices = employmentQuestionnaire.PrevocServices,
                                   HasJobDevelopmentServices = employmentQuestionnaire.JobDevelopmentServices,
                                   WhoCreated = employmentQuestionnaire.InsertUser,
                                   WhenCreated = employmentQuestionnaire.InsertDate,
                                   WhoUpdated = employmentQuestionnaire.UpdateUser,
                                   WhenUpdated = employmentQuestionnaire.UpdateDate,
                                   AvgRatePay = employmentQuestionnaire.PrevocService.AvgRatePay,
                                   AvgHoursWeek = employmentQuestionnaire.PrevocService.AvgHoursWeek,
                                   PrevocGoal = employmentQuestionnaire.PrevocService.PrevocGoal,
                                   SkillsTaught = employmentQuestionnaire.PrevocService.SkillsTaught,
                                   SkillsLearned = employmentQuestionnaire.PrevocService.SkillsLearned,
                                   AnticipatedTransitionPlan = employmentQuestionnaire.PrevocService.AnticipatedTransitionPlans,
                                   AnticipatedEndDate = employmentQuestionnaire.PrevocService.AnticipatedEndDate,
                                   TypeWorkDesired = employmentQuestionnaire.JobDevelopmentService.TypeWorkDesired,
                                   NeedEmpServices = employmentQuestionnaire.JobDevelopmentService.NeedEmploymentServices,
                                   IsDVRProvidingServices = employmentQuestionnaire.JobDevelopmentService.DVRProvidingServices,
                                   DVRCurrentReferralExists = employmentQuestionnaire.JobDevelopmentService.DVRCurrentReferral
                                };
    

    Basically, all the table relationships exist in your object structure. You do your query using your object relations and all the SQL joins are inferred by the attributes on your objects properties (set-up in the code generation step).

    A little trick, I always place the table on the “many” side of the relationship in the from clause so I can do myObject.Parent.Property. If I have a many-to-many table it is this one that is in the from clause. Doing this, I only need to use explicit joins for:

    • Left joins
    • Queries that need to fetch data in a many-to-one, to-one, … to-many. In that case the table that changes the relationship direction (from many-to-one to one-to-many) is the one in the join clause.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 237k
  • Answers 237k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Without a checkout, you can do the git fetch and… May 13, 2026 at 6:32 am
  • Editorial Team
    Editorial Team added an answer Try Mockingbird, it's mainly used for user interface prototypes, but… May 13, 2026 at 6:32 am
  • Editorial Team
    Editorial Team added an answer As far as the CUDA or OpenGL support is concerned… May 13, 2026 at 6:32 am

Related Questions

I need to run a shell command asynchronously from a Python script. By this
Banging my head against this one for a long time. On Rails 2.3.2, Ruby
This is somewhat of a follow-up to an answer here . I have a
Ok, I am going to try and give a very bried yet detailed description

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.