ok lets attempt to resolve it..
The problem is with the explicit cast of the
linq
query result to a
list
before assigning it to filtered list because by default the results of the
linq
query is returned in a generic collection that is why it allows you to use
var
type..so casting it to a
string
list would be impossible ( as in the case you previously wanted to do)
..so what you should do is to first create a generic list
List<string>
for all the previous lists you created and then secondly, in the
foreach
loop,
return the query to a variable with the
IEnumerable<string>
or the
var
type. (I would personally recommend the
IEnumerable<string>
type to avoid type and value ambiguity).
and then since its already an
enumerable generic collection type, you can easily copy all its contents directly into the
list
type you initially wanted to do
so I think you should modify that section of your code to look like this..
foreach(string item in words)
{
IEnumerable<string> q = from ci in list where ci.BodyContent.ToLower().Contains(item) select ci;
}