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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:49:52+00:00 2026-06-16T13:49:52+00:00

I’m a LINQ Newb and I’ve got this query, which returns the pages in

  • 0

I’m a LINQ Newb and I’ve got this query, which returns the pages in a survey. (These values are not materialized into a table, for whatever reason.)

//Group all of this data by page 
var pages = from fq in db.FormQuestions
        where (fq.FormId == id) && fq.Disabled == false
        group fq by fq.PageNumber into p
        select new DTOs.PageDTO { PageNumber = p.Key.Value };

And then I have this query, which projects all of the leaf-data into DTOs.

var questions = from fq in db.FormQuestions
   join q in db.Questions on fq.QuestionId equals q.QuestionId
   where (fq.FormId == id) && fq.Disabled == false
   //where (fq.FormId == id) && fq.Disabled == false && fq.PageNumber == page
   orderby fq.DisplayOrder
   select new DTOs.FormQuestionDTO()
   {
       DisplayOrder = (fq.DisplayOrder.HasValue ? fq.DisplayOrder.Value : 0),
       PageNumber = (fq.PageNumber.HasValue ? fq.PageNumber.Value : 0),
       QuestionId = q.QuestionId,
       QuestionSelectionMode = q.vts_tbQuestionSelectionMode.Description,
       QuestionText = q.QuestionText,
       Answers =
           from answer in q.Answers
           join at in db.AnswerTypes on answer.AnswerTypeId equals at.AnswerTypeID
           where answer.Disabled == false
           orderby answer.DisplayOrder
           select new DTOs.AnswerDTO()
           {
               AnswerId = answer.AnswerId,
               AnswerText = answer.AnswerText,
               DisplayOrder = answer.DisplayOrder,
               AnswerType = at.Description
           }
   };

Is there a way to join these two neatly? I.e., under each page DTO I want to see the QUestion DTOs, then inside of that Answer DTOs, and onward…

Also, even if I could do this all in one LINQ statement, is it preferable to build the LINQ statements separately and then merge them? This feels a bit like building temp variables in SQL in that it may be possible to build one giant query but it’s a pain to maintain.

  • 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-16T13:49:53+00:00Added an answer on June 16, 2026 at 1:49 pm

    So why wouldn’t something like this work?

    //Group all of this data by page 
    var pages = from fq in db.FormQuestions
            where (fq.FormId == id) && fq.Disabled == false
            group fq by fq.PageNumber into p
            select new DTOs.PageDTO { 
              PageNumber = p.Key.Value 
              questions = from fq in db.FormQuestions
                         join q in db.Questions on fq.QuestionId equals q.QuestionId
                         where (fq.FormId == id) && fq.Disabled == false
                         orderby fq.DisplayOrder
                         select new DTOs.FormQuestionDTO()
                         {
                           DisplayOrder = (fq.DisplayOrder.HasValue ? fq.DisplayOrder.Value : 0),
                           // etc as you 2nd code sample
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.