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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:02:06+00:00 2026-06-17T09:02:06+00:00

This is the query I am trying to do. var commentActivity = project.ProjectDoc .Select(c

  • 0

This is the query I am trying to do.

var commentActivity = project.ProjectDoc
        .Select(c => c.Comment.Select(i => i.UserID))
        .Distinct()
        .Count();

What I want is the number of comments from distinct users on a specific project, but ANY ProjectDoc. This query “works” the result is just wrong. The model is like this, generically sketched.

 Project
      ProjectDoc
           Comment

Update: I had to go one level deeper, based on the answer below I tried a few things that didn’t work so I though I would post this as a reference. Note the two SelectMany methods.

 var replyActivity = project.ProjectDoc
      .SelectMany(c => c.Comment.SelectMany(r => r.CommentReply.Select(u => u.UserID)))
      .Distinct()
      .Count();
  • 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-17T09:02:07+00:00Added an answer on June 17, 2026 at 9:02 am

    Use SelectMany instead of Select

    project.ProjectDoc
            .SelectMany(c => c.Comment.Select(i => i.UserID))
            .Distinct()
            .Count()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to do this query: SELECT * FROM TABLE WHERE value1='THIS'S AN EXAMPLE'.
I'm trying to introduce a join to this query: SELECT `n`.*, round((`n`.`rgt` - `n`.`lft`
I am trying to have information displayed for this query: SELECT o.sub_number,o.unique_id,o.period_from,o.period_to,o.total_amt, i.paid_amt,i.dated,i.payment,i.paid_by,i.entered_date,i.paid_for_unique, j.cheque_num,j.drawn_on,j.dated
I am trying to accomplish something like this query: var query = from a
I am trying to use the following linq query on my datagridview: var count
Suppose In SQL I am trying to run this query Select * from MyTable
I'm trying to generate this basic SQL statement using Query Expressions: SELECT * FROM
So what I'm trying to do is: Run this query: SELECT FW_ArtSrcLink FROM FW_ArtSrc
I am trying this code but i want to know what is the number
I have a problem with this query trying to get a sum and a

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.