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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:52:06+00:00 2026-05-20T18:52:06+00:00

I am trying to create 3 different lists (1,2,3) from 2 existing lists (A,B).

  • 0

I am trying to create 3 different lists (1,2,3) from 2 existing lists (A,B).
The 3 lists need to identify the following relationships.

  • List 1 – the items that are in list A and not in list B
  • List 2 – the items that are in list B and not in list A
  • List 3 – the items that are in both lists.

I then want to join all the lists together into one list.

My problem is that I want to identify the differences by adding an enum identifying the relationship to the items of each list. But by adding the Enum the Except Linq function does not identify the fact (obviously) that the lists are the same. Because the Linq queries are differed I can not resolve this by changing the order of my statements ie. identify the the lists and then add the Enums.

This is the code that I have got to (Doesn’t work properly)
There might be a better approach.

        List<ManufactorListItem> manufactorItemList =
           manufactorRepository.GetManufactorList();

        // Get the Manufactors from the Families repository
        List<ManufactorListItem> familyManufactorList =
            this.familyRepository.GetManufactorList(familyGuid);

        // Identify Manufactors that are only found in the Manufactor Repository
        List<ManufactorListItem> inManufactorsOnly =
            manufactorItemList.Except(familyManufactorList).ToList();

        // Mark them as (Parent Only)
        foreach (ManufactorListItem manOnly in inManufactorsOnly) {
            manOnly.InheritanceState = EnumInheritanceState.InParent;
        }

        // Identify Manufactors that are only found in the Family Repository
        List<ManufactorListItem> inFamiliesOnly =
            familyManufactorList.Except(manufactorItemList).ToList();

        // Mark them as (Child Only)
        foreach (ManufactorListItem famOnly in inFamiliesOnly) {
            famOnly.InheritanceState = EnumInheritanceState.InChild;
        }

        // Identify Manufactors that are found in both Repositories
        List<ManufactorListItem> sameList =
            manufactorItemList.Intersect(familyManufactorList).ToList();

        // Mark them Accordingly
        foreach (ManufactorListItem same in sameList) {
            same.InheritanceState = EnumInheritanceState.InBoth;
        }

        // Create an output List
        List<ManufactorListItem> manufactors = new List<ManufactorListItem>();

        // Join all of the lists together.
        manufactors = sameList.Union(inManufactorsOnly).
            Union(inFamiliesOnly).ToList();

Any ideas hot to get around this?
Thanks in advance

  • 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-20T18:52:07+00:00Added an answer on May 20, 2026 at 6:52 pm

    You can make it much simplier:

    List<ManufactorListItem> manufactorItemList = ...;
    List<ManufactorListItem> familyManufactorList = ...;
    var allItems = manufactorItemList.ToDictionary(i => i, i => InheritanceState.InParent);
    
    foreach (var familyManufactor in familyManufactorList)
    {
        allItems[familyManufactor] = allItems.ContainsKey(familyManufactor) ?
                                     InheritanceState.InBoth : 
                                     InheritanceState.InChild;
    }
    
    //that's all, now we can get any subset items:  
    
    var inFamiliesOnly = allItems.Where(p => p.Value == InheritanceState.InChild).Select(p => p.Key);
    var inManufactorsOnly = allItems.Where(p => p.Value == InheritanceState.InParent).Select(p => p.Key);
    var allManufactors = allItems.Keys;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a view that will need 2 dropdown lists with MVC
Some info on the issue: I am trying to create a list that fills
I'm basically trying to create a linked list from a text file and add
I am trying to create an item list, diffrent for each i and j
I am trying to create two different sets of settings for datepicker( http://keith-wood.name/datepick.html )
Trying to create several layers of folders at once C:\pie\applepie\recipies\ without using several different
I'm trying to create a relation where any of four different parts may be
I'm trying to create a button with a rectangle since we're gonna have different
I am trying create a WCF service that leverages the WPF MediaPlayer on the
Trying to create a QtRuby application, I get the following error: /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2144: [BUG] Segmentation

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.