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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:20:50+00:00 2026-05-27T17:20:50+00:00

List<Comment> StreamItemComments = objStreamItem.GetComments(); … foreach (Comment Item in StreamItemComments) { if (ClientUser.UserName !=

  • 0
    List<Comment> StreamItemComments = objStreamItem.GetComments();

…

    foreach (Comment Item in StreamItemComments)
        {
            if (ClientUser.UserName != Item.Sender)
            {
                Notification notificationObj = new Notification
                {
                    Sender = ClientUser.UserName,
                    Recipient = Item.Sender,
                    Value = "whatever value here",
                    TrackBack = "",
                    IsRead = false
                };
                notificationObj.Add();
            }
        }

What if there are two ‘username’ in List in Item.Sender. I’d like to send a notification once to the user. Here if there are duplicate usernames it will send two notifications because i am not filtering out duplicate Item.Senders from the list in StreamItemComments.

  • 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-27T17:20:51+00:00Added an answer on May 27, 2026 at 5:20 pm

    Consider writing a query to state your intentions. You want the distinct senders of the item comments, but only where the sender is not the client user. Sounds like a query, does it not?

    var recipients = StreamItemComments
                        .Where(item => item.Sender != ClientUser.UserName)
                        .Select(item => item.Sender)
                        .Distinct();
    

    You can then use this query to build your notifications

    foreach (var item in recipients)
    {
        var notificationObj = new Notification
        {
             Sender = ClientUser.UserName,
             Recipient = item,
             ...
        }
    
        notificationObj.Add();
    }
    

    You could also fit this object construction into the query, as well, but with your .Add() invocation on each object, I left it out of the query. It wouldn’t be difficult to incorporate, although you’d still need to loop over the output and invoke .Add() for each result.

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

Sidebar

Related Questions

you have some info on an item and you got a list of comment
given this xml: <root> <list> <!-- foo's comment --> <item name=foo /> <item name=bar
I have a large threaded comment list. When a person replies the author gets
I have a list of comments. For every comment, there might be subcomments (kind
Suppose Song s have_many Comment s; How can I: Pull a list of all
I'm loading a comment list and try to replace the list I currently have
I need to get a list of Articles sorted by the latest Comment from
lets say i have a BlogPost aggregate root. it holds a List <Comment> .
Consider the following domain model: Issue - id - List<Comment> Entry - id -
:) I have the following classes: Dislike DislikedComment (Comment) MemberId (int) Comment Dislikes (List<Dislike>)

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.