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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:24:20+00:00 2026-05-17T17:24:20+00:00

My tables are structured as below: Questions id title 1 what is this? Answers

  • 0

My tables are structured as below:

Questions

id  title
1   what is this?

Answers

id   answer qid
1    an     1

I want to select the question and all the answers in one single row through LINQ?

How can i do 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-05-17T17:24:20+00:00Added an answer on May 17, 2026 at 5:24 pm

    In addition to Hasan’s answer, if you are using LinqToSql and your relationships are properly established, then the code should simply be:

    var question = questions.Single(x => x.Id == 3);
    

    Answers should then already be available to you through the property:

    var answers = question.Answers;
    

    Since presumably you have an actual relationship defined between question.Id and answer.Qid.

    Update:

    In response to OP’s comments, here is how you can get all the data back as one row:

    var questionAndAnswers = questions
        .Where(x => x.Id == 3)
        .Select(x => new 
        {
            QuestionId = x.Id, 
            Question = x.Title, 
            Answer1 = x.Answers[0].Answer,
            Answer2 = x.Answers[1].Answer,
            Answer3 = x.Answers[2].Answer
        }).Single();
    

    Will return an object with the question and 3 answers. Obviously adding more answers requires tweaking this statement, since it’s flattened.

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

Sidebar

Related Questions

I have 4 different tables that I want to join. The tables are structured
This could turn out to be the dumbest question ever. I want to track
This question is now solved - I used the below: And, problem solved thanks
newb question there. Having MySQL database/tables structure below: CREATE DATABASE `dbTest` CREATE TABLE IF
Similar to these other questions noted below, I have two tables with the structure:
Most questions revolving around the title of this post ask about making Hibernate, or
This is a follow up question to my prev one. I use the code
So I have two tables structured like so: CREATE TABLE #nodes(node int NOT NULL);
I have a table structured as following: I'm trying to select the latest handicap
I do not know how to classify this question. Vaguely, its about using calculated

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.