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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:48:40+00:00 2026-06-14T14:48:40+00:00

I am currently using Linq to retrieve a list of distinct values from my

  • 0

I am currently using Linq to retrieve a list of distinct values from my data table. I am then looping through the list and again calling a linq query to retrieve a list of values for each
value in the first list.

_keyList = new SortedList<int, List<int>>();
var AUGroupList = ProcessSummaryData.AsEnumerable()
                  .Select(x => x.Field<int>("AUGroupID"))
                  .Distinct()
                  .ToList<int>();
foreach (var au in AUGroupList)
{
    var AUList = ProcessSummaryData.AsEnumerable()
                      .Where(x => x.Field<int>("AUGroupID") == au)
                      .Select(x => x.Field<int>("ActivityUnitID"))
                      .ToList<int>();
    _keyList.Add(au, AUList);
}

I am then adding the value to a sorted list along with the corresponding second list.
How can I combine the above two queries into one Linq query so that I don’t have to call them separately?

  • 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-14T14:48:41+00:00Added an answer on June 14, 2026 at 2:48 pm

    You should be able to do something like:

    var groupQuery = from d in ProcessSummary.AsEnumerable()
                     group d by new { Key = d.Field<int>("AUGroupID") } into g
                     select new { GroupID = g.Key, Values = g.Distinct().ToList() }; 
    

    Then you can loop through the groupQuery and populate the sorted list. The Key property will contain the group id, and the Values property will have a distinct list of values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using LINQ to retrieve data from the Database, the variable name relative
I need to get two fields from a database table (retrieved using linq-to-sql), one
I'm using C# 3.5 and am currently using Linq to get all users from
Currently I'm using the following extension method that I made to retrieve the values
I am using LINQ for paging data in my website. I am currently using
Currently I am using the terrific Linq 2 Json.net (by newtonsoft), which is a
Currently using the HTTPServletRequest class and specifically the .getQueryString method to retrieve an inputted
I’m using NHibernate for data access, but accessing it through a façade layer. This
I am using LINQ-to-SQL. I have retrieved an Entity called FileType using FileTypeID from
I'm currently using Linq to sql as my OR-mapper. My problem is that i

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.