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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:24:20+00:00 2026-06-15T03:24:20+00:00

Based on this question: [How can I do SELECT UNIQUE with LINQ? I wrote

  • 0

Based on this question:

[How can I do SELECT UNIQUE with LINQ?

I wrote the below expression to select rows with unique OrganizationID column from the dt datatabe which contains multiple columns.

var distinctRows = (from DataRow dRow in dt.Rows
                    select new { col1 = dRow["OrganizationID_int"] }).Distinct();

but when I check distinctRows after the expression being executed, it only has records with 1 column (col1) instead of holding the whole columns. I afraid that adding expressions like col2=... and etc, may be interpreted that I want select distinct on all these columns.

So how can I get the whole row while applying unique filter on only 1 column but not the whole columns?

  • 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-15T03:24:21+00:00Added an answer on June 15, 2026 at 3:24 am

    I want the whole rows which satisfy that unique condition with all
    columns. I want to iterate in the next step.

    So you don’t want to group by that field and return one of the multiple rows. You want only rows which are unique.

    One way is using Enumerable.GroupBy and count the rows in each group:

    var uniqueRows = dt.AsEnumerable()
                       .GroupBy(r => r.Field<int>("OrganizationID_int"))
                       .Where(g => g.Count() == 1)
                       .Select(g => g.First());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this question is based on answer got from another SO question, can be found
This is a further question based on this answer: How can I implement a
I've tried checking out this question sql - distinct + select and can't seem
This is generic UI question. In my web application user can select color of
this question follows on from previous thread: XSLT: Sorting based on sum of values
I've seen this question: Select query but show the result from record number 3
Based on this question I've created a small application which is catching all debug
Based on this question I understand the purpose of the construct in linking C
Based on this question How to insert array into mysql using PDO and bindParam?
This question is based on this thread . Is [---] a comment in Git

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.