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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:19:30+00:00 2026-05-27T20:19:30+00:00

I am working on a c# project and writing a LINQ query, in this

  • 0

I am working on a c# project and writing a LINQ query, in this query I need to create a group, but I know I want to use that group type, but the type of the group gives me some trouble as I am not able to cast it to my desired type.

My Query is

from emp in employees
join dept in departments
on emp.EmpID equals dept.EmpID
group dept by dept.EmpID into groupSet
select new mycustomType
{
    Department = groupSet
});
  • 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-27T20:19:31+00:00Added an answer on May 27, 2026 at 8:19 pm

    You haven’t shown the signature of any of your types. We can only be guessing how your desired type might look. Next time you ask a question make sure you provide an SSCCE.

    Anyway, according to your example here’s how this custom type should look like:

    public class MyCustomType
    {
        public IGrouping<int, Department> Department { get; set; }
    }
    

    where Department is the type of elements inside the departments collection and it assumes that EmpID is of type integer.

    Example:

    IEnumerable<Employee> employees = ...
    IEnumerable<Department> departments = ...
    
    IEnumerable<MyCustomType> result = 
        from emp in employees
        join dept in departments
        on emp.EmpID equals dept.EmpID
        group dept by dept.EmpID into groupSet
        select new MyCustomType
        {
            Department = groupSet
        };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a project and want to optionally use an assembly if
i need some help with c# and nhibernate. I'm working on a project that
i'm writing project that stores data, so i need to compress it. I've tried
as opposed to writing your own library. We're working on a project here that
I'm working on a project in which i need to create two tables in
I am working on a project that creates two processes and I want to
I'm working on a project that uses MSTest for unit testing and I need
I'm currently working on this project that implies some DSP skills. I must extract
For a C project I'm writing I need to use the GMP library, which
I'm working on a project that involves writing low-level C software for a hardware

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.