I'm trying to find all element that contains all words in a phrase after geting them from database:
string text = "ab cd 23";//the element prop2 must have all 3 word regardless their order var q = from c in db.myTable where c.Prop1 == "value" select c; string[] strings = text.Split(' '); foreach(string word in strings) { int cnt = q.Count();//first time cnt = 1500 which is correct q = q.Where(c => c.Prop2.Contains(word));// Prop2 is a string cnt = q.Count();//first time cnt = 460 } everything is alright till this:
foreach(string word in strings)// second time { int cnt = q.Count();//second time cnt = 14 ?? q = q.Where(c => c.Prop2.Contains(word)); cnt = q.Count();//first time cnt = 2 } without doing anything at the second loop the element count changes furthermore this should return only element with all the words but it return element with just the last one and the third loop is useless changes nothing
I'm sorry for the long Q but I'm new to linq