1

我有以下课程:-

Blog.cs
public int BlogId { get; set; }
public string BlogTitle { get; set; }
public virtual ICollection<BlogTag> BlogTags { get; set; }

BlogTag.cs
public int BlogTagId { get; set; }
public string BlogTagName { get; set; }
public Blog Blog { get; set; }
public int BlogId { get; set; }

现在我需要获取包含 BlogTagName 的博客列表,所以我尝试了以下方法,但它无法正常工作:-

 var tags = viewModel.BlogViewModel.BlogList.Where(post => post.BlogTags.All(tag => tag.BlogTagName.Contains(tagName)));

我怎样才能得到这个工作?

谢谢

4

1 回答 1

3

AllAny灵魂代替

这将检查博客的“至少一个”blockTag 是否包含您的 tagName。

使用All,博客中的所有 blockTag 都应包含您的 tagName。

于 2013-01-11T10:32:52.247 回答