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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:16:36+00:00 2026-05-28T01:16:36+00:00

I have an existing table and a new table. The tables contain at least

  • 0

I have an existing table and a new table.
The tables contain at least two items that need to be checked.
I need to do the following items

1) Get a list of items that are not in the new table but are in the existing table. – So they can be removed
2) Get a list of items that are in the new table but not in the existing table – So they can be added

3) Get a list of items that are in both tables but the existing table needs updateing

Here is the data

var existingItems = new[] 
{ 
    new RetryItem { CellId = 1, Content = "Bob" }, 
    new RetryItem { CellId = 2, Content = "Bill" }, 
    new RetryItem { CellId = 3, Content = "Frank" }, 
    new RetryItem { CellId = 4, Content = "Tom" }, 
    new RetryItem { CellId = 5, Content = "Dick" }, 
    new RetryItem { CellId = 6, Content = "Harry" }, 
}; 

var newItemsLarger = new[] 
{ 
    new RetryItem { CellId = 1, Content = "Bob" }, 
    new RetryItem { CellId = 2, Content = "Bill" }, 
    new RetryItem { CellId = 3, Content = "Frank" }, 
    new RetryItem { CellId = 4, Content = "Tom now Thoams" }, 
    new RetryItem { CellId = 5, Content = "Dick now Dicky" }, 
    new RetryItem { CellId = 6, Content = "Harry Now Harriet" }, 
    new RetryItem { CellId = 7, Content = "Mary" }, 
    new RetryItem { CellId = 8, Content = "Mungo" }, 
    new RetryItem { CellId = 9, Content = "Midge" }, 
};
  • 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-28T01:16:37+00:00Added an answer on May 28, 2026 at 1:16 am

    You can use the following sample program in a console application:

    using System.Linq;
    
    namespace ExperimentConsoleApp
    {
        class Program
        {
            static void Main()
            {
                // Check if the item is in existingItems but not in newItems
                var itemsToBeRemoved = (from e in existingItems
                                        where !newItemsLarger.Any(n => n.CellId == e.CellId)
                                        select e).ToList();
    
                // Check if the item is in newItems but not in existingItems 
                var itemsToBeAdded = (from n in newItemsLarger
                                      where !existingItems.Any(e => n.CellId == e.CellId)
                                      select n).ToList();
    
                // Match the items on Id and check if their contents equals
                var itemsToBeUpdated = (from e in existingItems
                                        from n in newItemsLarger
                                        where e.CellId == n.CellId && e.Content != n.Content
                                        select n).ToList();
            }
    
            static RetryItem[] existingItems = new[] 
                            { 
                                new RetryItem { CellId = 1, Content = "Bob" }, 
                                new RetryItem { CellId = 2, Content = "Bill" }, 
                                new RetryItem { CellId = 3, Content = "Frank" }, 
                                new RetryItem { CellId = 4, Content = "Tom" }, 
                                new RetryItem { CellId = 5, Content = "Dick" }, 
                                new RetryItem { CellId = 6, Content = "Harry" }, 
                            };
    
            static RetryItem[] newItemsLarger = new[] 
                            { 
                                new RetryItem { CellId = 1, Content = "Bob" }, 
                                new RetryItem { CellId = 3, Content = "Frank" }, 
                                new RetryItem { CellId = 4, Content = "Tom now Thoams" }, 
                                new RetryItem { CellId = 5, Content = "Dick now Dicky" }, 
                                new RetryItem { CellId = 6, Content = "Harry Now Harriet" }, 
                                new RetryItem { CellId = 7, Content = "Mary" }, 
                                new RetryItem { CellId = 8, Content = "Mungo" }, 
                                new RetryItem { CellId = 9, Content = "Midge" }, 
                            };
        }
    
        public class RetryItem
        {
            public int CellId { get; set; }
            public string Content { get; set; }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DB table that already has an existing value that I don't
I have existing java code and need to create Design Document based on that.
I'm adding a new column, summary , to an existing table. It will contain
I have an existing database that contains 4 tables: categories, sub-categories, products, prices. I
Lets say I have a simple table that only contains two columns: MailingListUser -
I have a table that loads new data every day and another table that
I have quick question for you SQL gurus. I have existing tables without primary
I have an existing database with tables which each have 4 partitions (there are
I have an existing database with users and administrators in different tables. I am
I have the full copy of all the form authentication DB tables existing on

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.