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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:58:04+00:00 2026-05-20T04:58:04+00:00

I’m creating a linq query to get some data that will return a list

  • 0

I’m creating a linq query to get some data that will return a list of emails and some other info.

I’ve created the query so that i get the emails that i want, and the info. The thing is, it’s possible that the info will be the same for more than 1 email.

I want to know what’s the linq way to get a resultset that returns me something like

email1@domain.com,email2@domain.com  |   INFO
email3@domain.com  |   INFO2
email4@domain.com,email5@domain.com,email6@domain.com,email3@domain.com  |   INFO3

With the first property being a csv list of emails.

The query that I have right now is something like this :

from user in context.Users
join ufa in context.UFAccesses on user equals ufa.User
join f in context.F on ufa.Feed equals f
join fp in context.FP on f equals fp.F
select new { thisUfa = fp.F.UFAccess.Where(ufaSearch => ufaSearch.User == user && ufaSearch.F == f).FirstOrDefault(), user.Email, fp.Title, fp.Content };

EDIT : some extra info to help the answerer. maybe there’s a better way to do this. the main reason for the question is, since i’m getting this INFO several times (because it may correspond to more than 1 email), i’m getting innecessary data. later, i can do a loop in this resultset and for each info get a list of emails that correspond to it, but of course i’d like to get something more efficient and in linq if possible.

  • 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-20T04:58:05+00:00Added an answer on May 20, 2026 at 4:58 am

    This one should solve your problem:

    public class Something
    {
        public string Email { get; set; }
        public string Info { get; set; }
    }
    
    var list = new List<Something>();
    list.Add(new Something { Email = "email1", Info = "info1" });
    list.Add(new Something { Email = "email2", Info = "info2" });
    list.Add(new Something { Email = "email3", Info = "info3" });
    list.Add(new Something { Email = "email4", Info = "info3" });
    list.Add(new Something { Email = "email5", Info = "info3" });
    list.Add(new Something { Email = "email6", Info = "info1" });
    
    var groupedList = list.GroupBy(e => e.Info).Select(g => new { Info = g.Key, Emails = String.Join(",",g.Select(e => e.Email)) });
    

    First we are grouping with GroupBy(e => e.Info) and then selecting group key (Info) and joined emails:

    new { Info = g.Key, Emails = String.Join(",",g.Select(e => e.Email)) });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.