I have the following 2 entities in my db.
public class Article { [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } // Some code removed for brevity public virtual ICollection<Tag> Tags { get; set; } } public class Tag { [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } // Some code removed for brevity public virtual ICollection<Article> Articles { get; set; } }
I need to filter these articles based on the tag identifiers that are passed to my action.
public ActionResult FindAll(List<int> tags) {
For example, if I submitted to 1, 2, 3 in action, only those articles that had these 3 tags or more will be returned.
How can i achieve this?
Thanks for the great answer!
All your answers gave the correct result, so I did a quick, basic profiling in sql, and these were the results based on your queries.

source share