Good day. I'm trying perform select query with linq from collection of establishments. Establishment contains list of products it selling, but list of products can be empty. Well, I guess cause of that I get null exception. How I fix it and avoid null exception? This is my linq query:
var result = Establishments.Select(e => new
                {
                    ID = e.ID,
                    Name = e.Name,
                    Category = e.Category.Name,
                    XAdress = e.XAdress,
                    YAdress = e.YAdress,
                    CompanyName = e.Company.Name,
                    ProductsSelling = e.ProductsSelling.Select(p => new // error here
                    {
                        ID = p.ID,
                        Name = p.Name,
                        Category = p.Category.Name,
                        Price = p.Price,
                        Additives = p.PossibleAdditives.Select(a => new
                        {
                            ID = a.ID,
                            Name = a.Name,
                            Price = a.Price
                        })
                    })                    
                });
 
    