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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:40:50+00:00 2026-06-08T04:40:50+00:00

Please do not give me help in lamba I have two tables. Employees: pk

  • 0

Please do not give me help in lamba

I have two tables. 
Employees:   
pk           
name        

ExpenseTeamMembers: 
pk                        
expMgrPk
empPk

Example: pk      expMgrPk     empPk     
     1         7          81
     2         7          101
     3         13         99
     4         13         22
     5         13         56

Basically the first table is a list of employees and the second is a table for keeping track of which employees belong to which manager.

The first sql lookup works and mgr is getting me the pk of the selected name in the combo box.

What I am trying to do in the join is lookup the expMgrPk and see which employees belong to it and return their names instead of their pk. I am pretty off and need a little help. Again please do not give me help in lamba!! Thanks

    private void cboManagers_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (cboManagers != null)
        {
            string selectedMgr = (string)cboManagers.SelectedValue;

            using (DataClasses1DataContext db = new DataClasses1DataContext())
            {
                int mgr = (from f in db.employees
                          where f.name == selectedMgr
                          select f.pk).FirstOrDefault();

                var emps = (from m in db.employees
                            join t in db.expenseTeamMembers on m.pk equals t.pK
                            where t.expMgrPk == mgr
                            select m.name).ToList();
                lstSelected.DataSource = emps;
            }
        }
    }
  • 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-08T04:40:53+00:00Added an answer on June 8, 2026 at 4:40 am

    In linq-to-sql, you can write joins more easily by writing two from statements combined with a where statement. Something like this:

    var emps = (from f in db.employees
                from m in db.expenseTeamMembers
                where m.pk == mgr && f.pk == m.empPk
                select f.name).ToList();
    

    I’ve found this syntax to be easier and when your code is compiled, the query is converted to a traditional T-SQL join.

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

Sidebar

Related Questions

It does not matter what programming language. Can anyone please give me an idea
What is the difference? Are these the same? If not, can someone please give
I am going to be crazy I think. Please Help. I have a table
Please not that I fully understand this is a dumb ass idea, but its
Please do not flag this as a duplicate, I'm not asking about what is
Please do not mark it as a dupe of this question just yet: Bold
Please do NOT comment on bad practices used here. I am simply trying to
LATER EDIT: Please mention not only game programming books, but also more scientific/simulation oriented
I'm not sure this is the right forum if it's not please feel free
How to check for grid view empty or not please let me know

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.