I have the following classes :-
Blog.cs
public int BlogId { get; set; }
public string BlogTitle { get; set; }
public virtual ICollection<BlogTag> BlogTags { get; set; }
and
BlogTag.cs
public int BlogTagId { get; set; }
public string BlogTagName { get; set; }
public Blog Blog { get; set; }
public int BlogId { get; set; }
Now I need to get a list of Blogs that contain the BlogTagName, so I tried the following but it is not working properly:-
var tags = viewModel.BlogViewModel.BlogList.Where(post => post.BlogTags.All(tag => tag.BlogTagName.Contains(tagName)));
How can I get this working?
Thanks
replace
AllbyAnysould do the trickThis will check if “at least one” blockTag of the blog contains your tagName.
With
All, all of the blockTags from a blog should contain your tagName.