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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:32:07+00:00 2026-05-28T07:32:07+00:00

Im getting a table Tags from the db. the table has columns ID and

  • 0

Im getting a table Tags from the db.

the table has columns ID and TagName

I’m doing something like this to get a list of strings:

var taglist = Model.Tags.Select(x => x.TagName.ToLower()).ToArray();

then I’m comparing against another string array to get the strings that occur in both:

var intersectList = tagList.Intersect(anotherList);

I have my list, but now I also want the ID of each item remaining in the intersect list that corresponds to the tagList. (can just be an int array)

Can anyone help with a good way to do this?

  • 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-28T07:32:08+00:00Added an answer on May 28, 2026 at 7:32 am

    Don’t use intersect, it only works for collections of the same type. You could do a simple join or other form of filtering. It would be easiest to throw the string list into a HashSet and filter by tags that contain TagNames in that set. This way, you keep your tags unprojected so they keep their ids and other properties.

    var stringSet = anotherList.ToHashSet(StringComparer.OrdinalIgnoreCase);
    var tagList = Model.Tags.Where(t => stringSet.Contains(t.TagName)).ToList();
    

    And put them into a list. Don’t throw them into an array unless you specifically need an array (for use in a method that expects an array).

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

Sidebar

Related Questions

I'm getting data from a MySQL table that has 2 columns (idDoc, tag) describing
We have a database with a tables called 'Sites' This table has the columns,
I am designed a dynamic table for getting input from user. Each column of
I am getting random row from my table using the following query: SELECT value_id
I'm getting the same results from select length(column_name) from table as from select dbms_lob.getlength(column_name)
Rails and MySQL: I have a table with several boolean columns representing tags. I
I have an app that has posts, tags, and a tag_ref link table. I
I would like to be able to list the 10 most popular tags (subjects)
How can you get all rows in a table without getting the rows in
I have a two tables. TABLE 1 has id(PRIMARY)|RANK|WEBSITE |ADDRESS This is filled with

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.