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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:25:03+00:00 2026-05-27T17:25:03+00:00

I am stuck with a problem here. I am trying to compare items in

  • 0

I am stuck with a problem here. I am trying to compare items in a list to another list with much more items using linq.

For example:

list 1: 10,15,20
list 2: 10,13,14,15,20,30,45,54,67,87

I should get TRUE if all the items in list 1 occur in list 2. So the example above should return TRUE

Like you can see I can’t use sequenceEquals

Any ideas?

EDIT:

list2 is actually not a list it is a column in sql thas has following values:
<id>673</id><id>698</id><id>735</id><id>1118</id><id>1120</id><id>25353</id>.

in linq I did the following queries thanks to Jon Skeets help:

var query = from e in db
            where e.taxonomy_parent_id == 722
            select e.taxonomy_item_id;

query is IQueryable of longs at this moment

var query2 = from e in db
             where query.Contains(e.taxonomy_item_id)
             where !lsTaxIDstring.Except(e.taxonomy_ids.Replace("<id>", "")
                                                       .Replace("</id>", "")
                                                       .Split(',').ToList())
                                 .Any()
             select e.taxonomy_item_id;

But now I am getting the error Local sequence cannot be used in LINQ to SQL implementation of query operators except the Contains() operator.

  • 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-27T17:25:03+00:00Added an answer on May 27, 2026 at 5:25 pm

    How about:

    if (!list1.Except(list2).Any())
    

    That’s about the simplest approach I can think of. You could explicitly create sets etc if you want:

    HashSet<int> set2 = new HashSet<int>(list2);
    if (!list1.Any(x => set2.Contains(x)))
    

    but I’d expect that to pretty much be the implementation of Except anyway.

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

Sidebar

Related Questions

I am stuck with a small problem here.. What i am trying to do
So I'm stuck on a newbie problem once more :D I'm trying to mash
I'm a little stuck on a problem here. I'm trying to match multiple occurrences
I am trying to write merge sort and stuck here. What is the problem
I've got stuck in a problem with gflags when trying to find some memory
I am stuck in a printf problem. I would appreciate if I can get
I'm trying to create a Regex javascript split, but I'm totally stuck. Here's my
I've been trying to get an NHibernate ICompositeUserType mapping to work. But am stuck
Here is my current problem: I am trying to create a file of x
I'm trying to implement DSA signature algorithm and I'm stuck on a problem. I'm

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.