i have removed all unnecessary variables andtried to focus directly on the problem at hand. I have a variable that can return null values:
var ppl = from p in xyz.new_ppl
select new
{
p.name
};
I query it and add it to a list:
foreach (var peeps in ppl)
{
peopleList.Add(peeps.name);
peopleNames = peopleList;
}
This works when i add a where clause to check before the select statement to check for null values using this statement
where p.name != null
What i want to be able to do is allow null values to be added. so i tried firstordefault but that didnt work
name = p.name.FirstorDefault()
the error says that i can’t cast a char to string. peopleNames is a setter, getter method of type string. Any workaround or solution?
would you like to try it like this?