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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:39:51+00:00 2026-06-14T16:39:51+00:00

I’m after some help with some Visual Studio C# code. I have a data

  • 0

I’m after some help with some Visual Studio C# code.

I have a data table with some rows & data like below:

Id      CodeNum     LineNum
1023503     4001        1
1023504     4001        1
1023505     4001        1
1023506     4002        1
1023507     4002        1
1023508     4002        1
1023509     4002        1
1023510     4003        2
1023511     4003        2
1023512     4003        2
1023513     4003        2
1023514     4004        2
1023515     4004        2
1023516     4005        3
1023517     4005        3
1023518     4006        3
1023519     4006        3
1023520     4006        3
1023521     4007        4
1023522     4007        4
1023523     4008        4
1023524     4009        5
1023525     4009        5
1023526     4009        6   x
1023527     4010        6
1023528     4011        6

I need to write a method to do an error check on all the table rows and ensure that any CodeNum only have one LineNum assigned to it.
eg rows with CodeNum 4002 has only LineNum 1 assigned to it, & say rows with CodeNum 4005 has only LineNum 3 assigned to it.

Its OK for a LineNum to be associated with more than one CodeNum but not a CodeNum to be associated with more than one LineNum value.

There is an error in the example above where the 3rd row with CodeNum 4009 has LineNum 6 instead of 5, here’s where I want an error message to pop up saying something like Error row id 1023526.

The real table/data contains many rows and there is no pattern to the CodeNum values and LineNum values, (all the values are integers).

I hope that makes sense.
I’m struggling to think of a quick succinct way to code this error check method.

  • 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-14T16:39:53+00:00Added an answer on June 14, 2026 at 4:39 pm

    You could convert to a lookup and then search for groupings with a count > 1:

    using System.Linq;
    
    var badRecords = collection.ToLookup(x => x.CodeNum).Where(y => y.Count() > 1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I would like to run a str_replace or preg_replace which looks for certain words

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.