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

The Archive Base Latest Questions

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

I have 2 lists that I am trying to compare, sadly they are not

  • 0

I have 2 lists that I am trying to compare, sadly they are not of the save class. One is from the magento api and the other is a custom class containing some values from the other. (only the ones that I need)

if (existingPhotoOrders.Where(x => x.OrderNumber.CompareTo(order.increment_id) == 0).ToList().Count > 0)
                continue;

There is a problem with the API where I have to get all the orders and compare the ones that I want and then request individually extra information but the above query is not working it is just continueing with everything.

I have looked at other comparisons but they all require the classes to be the same. If anyone could shed some light I would be grateful.

  • 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:33:27+00:00Added an answer on May 28, 2026 at 1:33 am

    It can be re-written like so using the Any method:

    if (existingPhotoOrders.Any(x => x.OrderNumber.CompareTo(order.increment_id) == 0))
        continue;
    

    As to why it is always continuing, the expression must always be true! I presume the requirement is if the order increment id is not an order number of an existing order then continue, in which case, you can use the All method:

    if (existingPhotoOrders.All(x => x.OrderNumber.CompareTo(order.increment_id) != 0))
        continue;
    

    Or as a more performant alternative:

    var orderIds = new HashSet<int>(existingPhotoOrders.Select(epo => epo.OrderNumber));
    foreach (var order in orders)
    {
      if (!orderIds.Contains(order.increment_id))
      {
        continue;
      }
      // rest of method here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two lists that I am trying to compare with < or >
I have been trying to serialize a list that contains arrays and lists. I
I have a list that I am trying to fill with numbers from a
I have a test list that I am trying to capture data from using
I have 2 lists I am trying to compare. I execute the following and
I have two tables that I need to compare and update values in one
I have Python nested list that I'm trying to organize and eventually count number
I'm trying to solve the following problem in Redis. I have a list that
I have a List of customers that I'm trying to bind to a DataGridView.
I have a C# list collection that I'm trying to sort. The strings that

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.