Why the code below returns nothing when I try to query an IList
type object?
IList<Person> personRecord = new List<Person>
{
new Person{ Name = "Samuel"},
new Person{ Name = "Kenny Sammy"},
new Person{ Name = "Jame Sam Lee"}
};
var names = from b in personRecord
where personRecord.Any(d => d.Name == "Sam")
select b;
return names.ToList();
Don't use
Any
simply use the condition inWhere
clause like:or with a method syntax:
If you are looking to match partial contents then use
Contains
like:To compare partial content with ignoring case use
IndexOf
like: