I am trying to write something similar to the following with LINQ:
var media = from s in db.Media select s;
string[] criteria = {"zombies", "horror"};
mediaList.RemoveAll(media.Where(s => s.description.Inersect(criteria).Any()));
//mediaList is a List(T) containing instances of the Media model.
I thought linq where list contains any in list's solution would apply in this case but my compiler complains that "string does not contain a definition for Intersect".
The behaviour I am expecting is for Media items that contain the words zombies or horror but not both in their description to be taken out of the list i.e.
- A horror movie.
- A movie with a lot of zombies.
But items like the following should stay in the list:
- A horror movie with zombies.
- The best zombies and the best horror.
The Media class:
public class Media
{
public int mediaID { get; set; }
public string type { get; set; }
public string description { get; set; }
}
The description field contains very long paragraphs. I am afraid the solution is very obvious but for the life of me I cannot work it out.
EDIT: added a better explanation of the behaviour expected.