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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:56:23+00:00 2026-06-15T22:56:23+00:00

I am trying to remove elements from an IEnumerable type from another IEnumerable. Here

  • 0

I am trying to remove elements from an IEnumerable type from another IEnumerable.

Here I get the complete list

var tiposObj = from t in context.sistema_DocType
                               select
                                   new tgpwebged.Models.SettingsModels.TipoIndiceModel
                                   {
                                       id = t.id,
                                       tipo = t.tipoName
                                   };

                classificacaoModel.tipos = tiposObj.ToList();

And here a partial list to be excluded from the first

  var tiposAtribuidosObj = from t in context.sistema_DocType
                                        join c in context.sistema_ClassificacaoTipo on t.id equals c.idTipo
                                        where c.idClassificacao == classificacaoId
                                        select new tgpwebged.Models.SettingsModels.TipoIndiceModel
                                        {
                                            id = t.id,
                                            tipo = t.tipoName
                                        };
                classificacaoModel.tiposAtribuidos = tiposAtribuidosObj.ToList();   

Here is how I am excluding:

classificacaoModel.tiposNaoAtribuidos = classificacaoModel.tipos.Except(classificacaoModel.tiposAtribuidos);

No elements is excluded from the first list. Can´t figure out why. They have same structure and same types.

  • 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-15T22:56:24+00:00Added an answer on June 15, 2026 at 10:56 pm

    .NET framework has no way to compare 2 instances of TipoIndiceModel.
    For this you have to implement IEqualityComparer or derive from EqualityComparer.

    Hint from MSDN on Except:

    This interface supports only equality comparisons. Customization of
    comparisons for sorting and ordering is provided by the IComparer
    generic interface.

    We recommend that you derive from the EqualityComparer class
    instead of implementing the IEqualityComparer interface, because
    the EqualityComparer class tests for equality using the
    IEquatable.Equals method instead of the Object.Equals method. This
    is consistent with the Contains, IndexOf, LastIndexOf, and Remove
    methods of the Dictionary class and other generic
    collections.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to add and remove elements from a list mapped as .HasMany(),
In this multi-thread program I'm trying to remove two random elements from a list
I am trying to remove elements from a std::list and keep some stats of
I am trying to remove elements from a Dictionary<string, List<string>> in C# when the
I am trying to remove comments from a list of elements that were obtained
I'm trying to remove all of the spaces from elements in a list of
I am trying to remove all HTML elements from a String. Unfortunately, I cannot
I'm trying to remove event listeners from elements after they've been clicked on and
I'm trying to pass elements from a list to a for loop and of
I am trying to remove all script elements from a HTML page. But for

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.