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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:28:58+00:00 2026-06-02T05:28:58+00:00

Please look at the following: DataTable newTable = new DataTable(); DataColumn colRMID = new

  • 0

Please look at the following:

        DataTable newTable = new DataTable();
        DataColumn colRMID = new DataColumn();
        colRMID.DataType = typeof(System.Int32);
        colRMID.ColumnName = "RMID";

        DataColumn colCpty = new DataColumn();
        colCpty.DataType = typeof(System.String);
        colCpty.ColumnName = "Cpty";

        newTable.Columns.Add(colRMID);
        newTable.Columns.Add(colCpty);

        DataRow r1 = newTable.NewRow();
        r1["RMID"] = 1234;
        r1["Cpty"] = "Internal";
        newTable.Rows.Add(r1);

        DataRow r2 = newTable.NewRow();
        r2["RMID"] = 5678;
        r2["Cpty"] = "Wales Fargo";
        newTable.Rows.Add(r2);


        DataRow r3 = newTable.NewRow();
        r3["RMID"] = 1234;
        r3["Cpty"] = "External";
        newTable.Rows.Add(r3);
        DataRow r4 = newTable.NewRow();
        r4["RMID"] = 9876;
        r4["Cpty"] = "Internal";
        newTable.Rows.Add(r4);

I would like to remove all the duplicate rows (having same “RMID”) where “Cpty” = “Internal”.
So that my final output in a datatable should be:

RMID  Cpty
5678 "Wales fargo"
1234 "External"
9876 "Internal"

I need to use LINQ

Thanks,
Abhinav

  • 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-02T05:29:01+00:00Added an answer on June 2, 2026 at 5:29 am

    This is not entirely efficient but it is verbose and demonstrates the concept. It also yields the result that you want. I’m sure you can clean it up to better suit your needs.

            var excludes = newTable
                .AsEnumerable()
                .GroupBy(row => row.Field<int>("RMID"))
                .Select(groupedRows => new { Rows = groupedRows, Count = groupedRows.Count() })
                .Where(groupedRows => groupedRows.Count > 1)
                .Select(groupedRows => groupedRows.Rows.Single(row => row.Field<string>("Cpty") == "Internal"))
                .Select(row => new { Rmid = row.Field<int>("RMID"), Cpty = row.Field<string>("Cpty") });
    
            var filteredSet = newTable
                .AsEnumerable()
                .Select(row => new { Rmid = row.Field<int>("RMID"), Cpty = row.Field<string>("Cpty") })
                .Except(excludes);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

am new here. i have a slight problem; PLease look at the following code
please look at the following code first. #! /usr/bin/perl package foo; sub new {
Please look at the following code: client.Credentials = new NetworkCredential(SMTP_SERVER_USERNAME, SMTP_SERVER_PASSWORD); client.EnableSsl = false;
Please have look on the following code: $_SESSION[process_y] = new Process(); $process_y = $_SESSION[process_y];
Please have a look a the following code sample, executed on a Windows-32 system
Please look at the following code snippet. I'm getting a nullreferenceexception at this.directories.Add(new directory(s));.
Getting the above error in following code. How to rectify it. Thanks. Please look
Please take a look at the following .htaccess ErrorDocument 404 /404/ RewriteEngine On RewriteRule
In my current project, Workflows have comments. Please have a look at the following
Please look at the following program, the error is invalid effective address calculation and

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.