I am trying to add
List.GroupBy(a=>a.ProductType.Name).Select(a=>a.FirstOrDefault()), now here I can have null values for .ProductType or .name so how can I ignore null values in C#, so I can get proper results of GroupBy?
If I am using above query in C#, I am getting error
Object reference not set to an instance of an object
I tried to make it like
List.GroupBy(a=>a.ProductType != null ? a.ProductType), but it doesn't work.
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly