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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:42:08+00:00 2026-05-21T08:42:08+00:00

i have a datatable which contains InvalidCodes. Before uploading the data to database(data is

  • 0

i have a datatable which contains “InvalidCodes”.

Before uploading the data to database(data is still in datatable), i want to perform linq on the datatable to remove Invalid entries and move them in another datatable

datatable allEntries ( entries yet to be uploaded in database)
datatable InvalidCodes(single column datatable – retrieved from database)
datatable invalidEntries

right now “allEnties” contains valid entries and invalid entries. the linq query on “allEntries” should move the nonexistend code entries to invalidEntries datatable.

plz help me perform this.

below is the query i formed but its not valid

string query = "select [CityCode] from [StateCity] ";
DataTable citylist = getDataTableFromSelect(query);

var result = from myrow in inputDt.AsEnumerable()
             where !myrow.Field<string>("CityCode").Contains(from myrow2 in citylist.AsEnumerable() select myrow2.Field<string>("CityCode") )
             select myrow;
  • 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-21T08:42:09+00:00Added an answer on May 21, 2026 at 8:42 am

    I’d make a HashSet for the invalid city codes – this will allow the code to quickly/efficiently identify which of the codes are in the invalid set.

    e.g. something like:

    var invalidCityCodes = from myrow2 in citylist.AsEnumerable()
                           select myrow2.Field<string>("CityCode");
    
    var invalidCityCodeHashSet = new HashSet<string>(invalideCityCodes);
    
    var result = from myrow in inputDt.AsEnumerable()
                 where !invalidCityCodeHashSet.Contains(myrow.Field<string>("CityCode"))
                 select myrow;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataTable which contains data in this format. I want to convert
I have a DataTable which I want to save to a SQLite Database Table.
I have a DataTable which I select from database (Well, these data cross several
I have a datatable which contains following data as SrNo Roll Name 1 1
In C#/ASP.NET 3.5, I have a DataTable which pulls rows from the database. I
I have a System.Data.DataTable which is populated by reading a CSV file which sets
I have a datagridview which im binding DataTable to. What I want do is
I have multiple excel files which I open as datatable I want to merge
I have a form which contains a DataGridView, a BindingSource, a DataTable, and a
Team, I have build a VB.Net windows application which does uploads data into database

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.