this may be a simple answer.
I'm making this LINQ expression where I group a list by "Name" and then I create a collection of SymbolFields where the group key (name) is used as name and the values are joined together as the second parameter.
But the question is more, how do I avoid possible null references?
If you look at the picture, you can see that there "might" be scenarios where group.key
is null.
I only want to select the ones that are NOT NULL. How can I do so based on my code?
return result
.GroupBy(r => r.Name)
.Select(group =>
new SymbolField(group.Key, string.Join(string.Empty, group.Select(g => g.Symbol))));