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

So I am trying to retrieve a list of blog entries, which has a
I have a blog that has a redirect loop, and I can't understand htaccess
I have a list of object that, among other bits of data, include a
I have a blog installed in www.foo.com/wp/ and would like all requests that go
What I would like to do is have a common Service class which has
I found a blog entry which suggests that sometimes c# compiler may decide to
The situation is as follows: I have a ViewModel that has a property that's
I am trying to get list of recent posts from a blog filtered by
I want to create a simple blog example where users have a favourite category
I'm writing a blog engine in rails, and have set up a tag model

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.