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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:54:12+00:00 2026-05-17T16:54:12+00:00

I am aggregating multiple List’s into one List and would like to make it

  • 0

I am aggregating multiple List’s into one List and would like to make it distinct based on one of the properties of Foo (Foo.Prop1).. I do not have access to modify Foo’s Equality comparer.

Dictionary<string, List<Foo>> fooDictionary = new Dictionary<string, List<Foo>>();
List<Foo> foovals = (from e in fooDictionary
                     where e.Key == "foo1" || e.Key == "foo2" || e.Key == "foo3"
                     select e.Value).SelectMany(f => f).ToList();

the only thing missing here is the .Distinct() at the end, to make Foo’s unique, however, in my case, i can’t modify anything about Foo, so simply calling Distinct() will not work.

Is there a way to modify this query to return items Distinct based on Foo.Prop1 ?

  • 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-17T16:54:13+00:00Added an answer on May 17, 2026 at 4:54 pm

    You could use the DistinctBy method in MoreLINQ:

    var query = fooVals.DistinctBy(foo => foo.Property1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble aggregating multiple arrays into one big array, I think this should
I can not distinguish the difference between aggregating and holding. What does it mean
Why would someone use a group by versus distinct when there are no aggregations
I am looping through all my databases and aggregating the results into an aggregates
Following up my previous question about aggregating hourly data into daily data, I want
I understand there are multiple questions about this on SO, but I have yet
I am interested in doing something like link aggregation over the data connection on
I've got a simple little web app that's aggregating a couple views from some
I am in the process of writing a web-app that uses multiple web APIs.
I'm searching for tool/database/solution that can help me with aggregating real-time logs and can

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.