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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:54:41+00:00 2026-05-17T20:54:41+00:00

So I have a Blog object which has a list of tag objects (

  • 0

So I have a Blog object which has a list of tag objects (List<Tag>).

I’m trying to create a method that takes a list of tags and returns a list of blogs that contain all the tags in the passed in list.

I was able to make a method that will return a list of blogs if it matches one tag, but not a list of tags.

to do that I have this

entities.Blogs.Where(b => b.Tags.Any(t => t.Name == tagName))

But I can’t figure out how to do something like this

entities.Blogs.Where(b => b.Tags.Any(t => t.Name == tags[0] AND t.Name == tags[1] AND t.Name == tags[2] etc.......))

Is there any way to do this?

Thank you!

I’m using LINQ to Entities

  • 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-17T20:54:42+00:00Added an answer on May 17, 2026 at 8:54 pm

    Logically, I think you want something like:

    entities.Blogs.Where(b => tags.All(t => b.Tags.Any(bt => bt.Name == t)))
    

    Alternatively:

    HashSet<string> tagNames = new HashSet<string>(tags);
    return entities.Blogs
                   .Where(b => tagNames.IsSubsetOf(b.Tags.Select(x => x.Name)));
    

    If this is using LINQ to Entities, I doubt that this will work – but it should work if you’re just using LINQ to Objects. Even then, it’s not going to be terribly efficient. I suspect there’s a more efficient way of doing things, but I can’t immediately think of it… it feels like you want a join, but then it gets tricky again.

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

Sidebar

Related Questions

I have parsed XML file into objects, in which each object has a 1:1
I'm starting a Wordpress Blog that will have adult content on it, so I'll
I have a web service that accepts an Invoice, which contains LineItem children. It
i have a wordpress blog and want to give people the same user experience
I have to store blog style comments in a database. Each comment can have
I have followed the blog post written by Steve Sanderson at blog.codeville.net/2008/10/14/partial-requests-in-aspnet-mvc . It
I am new to Ruby on Rails, I have completed the Blog Tutorial .
I have read the very good blog post of Rob Conery Crazy Talk: Reducing
Lately I have seen a lot of blog posts concerning how to build loosely
So I have this .htaccess file in the /blog/ folder on my webserver and

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.