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

  • Home
  • SEARCH
  • 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 9160753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:48:42+00:00 2026-06-17T13:48:42+00:00

I have two different collections like below public class Student { public int StudentID

  • 0

I have two different collections like below

public class Student
{
    public int StudentID { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }      
}

public class Skills
{
    public int SkillID { get; set; }
    public int StudentID { get; set; }
    public string Keyskill_Name { get; set; }        
    public int LastUsedYear { get; set; }
}

Here one student can contain multiple keyskils

I just want to fill a new collection like below

public class StudentDetails
{
    public int StudentID { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public list<string> Keyskill_Name { get; set; }
}

Please help me. Thanks in advance.

  • 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-17T13:48:43+00:00Added an answer on June 17, 2026 at 1:48 pm

    The GroupJoin LINQ method is the perfect solution for this case:

        List<Student> students = new List<Student>();
        List<Skills> skills = new List<Skills>();
    
        List<StudentDetails> studentDetails = students.GroupJoin(skills, student => student.StudentID, skill => skill.StudentID, (student, skillsForStudent) => new StudentDetails
        {
            FirstName = student.FirstName,
            LastName = student.LastName,
            StudentID = student.StudentID,
            Keyskill_Name = (from skill in skillsForStudent
                             select skill.Keyskill_Name).ToList()
        }).ToList();
    

    How to use the GroupJoin method?

    • Call the method from the set that gives a 1 to 1 relation with the result (Here for each Student, there is one and only one corresponding StudentDetails.
    • The first argument of the method is the set you want to “distribute” on the other items (Here the skills are “distributed” over the entire set of students)
    • The second and third arguments are used to explain how to make the collision between the elements of the first set and the elements of the second set. Lambda expressions are extremely useful in this case.
    • Lastly, the fourth argument, is used to define the result. It is a function with 2 parameters : an element of the first set (here students) and its corresponding elements in the second set that have been found using the collision.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two different collections: List<int> IEnumerable<IDataRecord> The first contains a list of primary
I have two different tables, lead and click. I would like to query MySQL
I have two collections. people are connected with a location like so: location_id =
I have two collections. var a = new List<string>() { a, b, c, d,
Let's say you have two collections of integers: IEnumerable<int> col1=new List<int> {2,3,3,5,7,11,11,11,13}; IEnumerable<int> col2=new
I have two collections of objects of different type. Lets call them type ALPHA
I have two Generic lists having objects of class : class Subject { public
I have two datasets returning to two different backbone collections each using a different
Can I contain two different types in a collection? For example, can I have
I have two different libGL libraries on the same Ubuntu 11.04 machine. One library

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.