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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:13:03+00:00 2026-05-17T16:13:03+00:00

Situation: TableParent with 2 primaryKeys, ParentKey1 and ParentKey2 TableChild with 1 primaryKey, ChildKey TableConnector

  • 0

Situation:

TableParent with 2 primaryKeys, ParentKey1 and ParentKey2
TableChild with 1 primaryKey, ChildKey
TableConnector with columns ParentKey1, ParentKey2 and ChildKey

This is where I think I should go with my Linq query. Notice I’m fetching all childs belonging to a parent so I have it’s keys as parameters.

var query = from conn in db.TableConnector
            join child in db.TableChild on conn.ChildKey equals child.childKey
            join par in db.TableParent on conn.ParentKey1 equals par.parentkey1 into connGroup
            from co in connGroup
            where co.ParentKey1 == Parameter1
            Select child;

Well I tthink this works up to a point, let’s say if parent had only one key, am I right?

I guess I have to join some more into a second group but I’m currently lost.

  • 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-17T16:13:03+00:00Added an answer on May 17, 2026 at 4:13 pm

    Firstly, you don’t have two primary keys on your table. You can only have one primary key (hence the name primary). It sounds like you have a composite primary key, which means a key that is composed of more than one column.

    I’m not sure what problem you are trying to solve, but it seems to be retrieving all TableChild rows for a given TableParent key. It should be something like this:

    db.TableParent
        .Single(parent => parent.ParentKey1 == key1 && parent.ParentKey2 == key2)
        .TableConnectors.Select(connector => connector.TableChild)
    

    If you have your tables mapped correctly on your Linq-to-Sql designer then you don’t have to manually join them – that’s what the Linq-to-Sql code generation does for you.

    For example, when you have a TableConnector you will be able to retrieve the TableChild rows for it using something like this

    TableConnector t = db.TableConnectors.First();
    List<TableChilds> tableChilds = tableConnector.TableChilds.ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Situation: text: a string R: a regex that matches part of the string. This
Situation: I am trying to write a efficient query using "LIKE" statement to look
Situation I'd like to make an RPC interface easier to use. This is a
Situation According to this accepted answer , if the " GC 'sees' a cyclic
Situation: I'm implementing a list-like container that supports a Pop() function that should return
Situation: I am working on a Qt4 application constructed in this way (in case
Situation is a string that results in something like this: <p>This is some text
Situation : I have a keydown handler with a switch for what key is
Situation: I have a database that contains sales records, each record has a ID
Situation: I have a simple XML document that contains image information. I need to

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.