I have the following linq query:
private List<Port> DoCountriesSearch(string search)
{
return Countries.Where(x => x.CountrySearch.ToLower().Contains(search.ToLower())).ToList();
}
I have an object called Countries
which is a list of Port objects with various properties. Each Port object contains a property called CountrySearch
which you can see here:
But as soon as I try to run the linq query on Countries
, suddenly the CountrySearch
property is null which throws a null reference exception:
I've never had this issue with linq before. What am I missing?