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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:23:54+00:00 2026-05-20T11:23:54+00:00

I have three domain objects: Child, Classroom and ChildClassroom. Here are lists of each:

  • 0

I have three domain objects:

Child, Classroom and ChildClassroom. Here are lists of each:

var childrens = new List<Child>() {
    new Child() { ChildId = 1, FirstName = "Chris" },
    new Child() { ChildId = 2, FirstName = "Jenny" },
    new Child() { ChildId = 3, FirstName = "Dave"  },
};

var classrooms = new List<Classroom>() {
   new Classroom() { ClassroomId = 1, FullName = "Kindergarten" },
   new Classroom() { ClassroomId = 2, FullName = "Elementary"   },
   new Classroom() { ClassroomId = 3, FullName = "Secondary"    },
};

var childclassrooms = new List<ChildClassroom>() {
   new ChildClassroom() { ClassroomId = 1, ChildId = 1 },
   new ChildClassroom() { ClassroomId = 2, ChildId = 1 },
   new ChildClassroom() { ClassroomId = 3, ChildId = 2 },
};

What I want is:

 var childClassroomRelationships = new object[] {
     new {
         childid = 1,
         classrooms = new object[] {
            new { classroomId = 1, occupied = true  },
            new { classroomId = 2, occupied = true  },
            new { classroomId = 3, occupied = false }
     },
     ...
 };

What’s the way to go about this in Linq?

  • 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-20T11:23:54+00:00Added an answer on May 20, 2026 at 11:23 am
    var kidsInClass = (
        from kid in childrens
        from c in classrooms
        select new {
            ChildID = kid.ChildId,
            classrooms = (
                from cc in childclassrooms
                select new {
                    ClassroomID = c.ClassroomId,
                    Occupied = cc.ChildId == kid.ChildId
                }).ToArray()
        }).ToArray();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a website with three domains .com, .de and .it Each domain needs
I have three domain objects defined as : class Member { String name static
Introduction Let's say I have three Domain Objects: Proposition Phase Task A Proposition can
I have three projects in my C# 4 solution. MooDB: Has my domain objects
In my application I have Users, Organisations and Employees. There are domain objects for
I have three domain class class Stock { Product product } and class Product
If I have a List in a Grails domain class, is there a way
i have list of departments and each department might have a parent or not
We have several domain objects which need to support both read-only and read-write modes;
I have been working on a new MVC application that utilizies EF4, POCO Domain

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.