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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:55:06+00:00 2026-05-11T09:55:06+00:00

I’m not sure if an answer for this already exists, as I can’t figure

  • 0

I’m not sure if an answer for this already exists, as I can’t figure out what mechanism in Linq is meant for this situation, or if I just need to do it manually.

Let’s say I have 2 tables:

------------Employees------------- EmployeeID  Name  -other columns-     ---------EmployeeSkills-----------    EmployeeID  Skill  -other columns- 

So each employee can have 0 or more skills.

My goal is to draw this information into a data structure in memory, using one sql query

    class StaticEmployee     {         int EmployeeID;                string Name;         List<string> Skills;     }     List<StaticEmployee> employees = (???).ToList(); 

Since my table relations are setup, I could just foreach the employees table (from employee in db.Employees select employee), however when I access the EmployeeSkills property, it is going to execute a seperate query for every employee record since that data wasn’t returned with the first query.

Alternatively, and I what I want done so far as Sql is concerned, is run a query with a left join:

SELECT Employees.EmployeeID, Employees.Name, EmployeeSkills.Skill FROM Employees LEFT JOIN EmployeeSkills ON Employees.EmployeeID=EmployeeSkills.EmployeeID 

That will get me my list, but I’ll need to manually collate it into my list since an employee with 2 skills will return 2 rows. Is there a Linq operation that does this? Hypothetical example below

from employee in db.Employees select new  {    EmployeeID = employee.EmployeeID,     Name = employee.Name,    Skills = new List(                      from employeeSkill in employee.EmployeeSkills                       select employeeSkill.skill                     ) } 
  • 1 1 Answer
  • 2 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. 2026-05-11T09:55:07+00:00Added an answer on May 11, 2026 at 9:55 am
    var options = new DataLoadOptions(); options.LoadWith< Employees>(e => e.EmployeeSkills); context.LoadOptions = options; //retrieve employees, they will come loaded with EmployeeSkills 

    If you were to use the linq query version instead, this will load them once as well:

    from employee in db.Employees select new  {    EmployeeID = employee.EmployeeID,     Name = employee.Name,    Skills = employee.EmployeeSkills } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
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.