0

I have an array of categories and a list of products (default Linq datasource) and I need to perform a left join that would give me something like this :

catA: prodA 
catA: prodB 
catB: (No Products) 
catC: prodC

This is what I wrote so far but it only gives me the categories that have products, basically the evquivalent of catB doesn't show. I'm just not sure what to do next. I must use method query. The result is specified as a a pair string, string:

public static IEnumerable<(string category, string productName)> LeftOuterJoin()
        {
            string[] categories =
            {
                "Beverages",
                "Condiments",
                "Vegetables",
                "Dairy Products",
                "Seafood"
            };

            List<Product> products = Products.ProductList;

            return categories.Join(products, category => category, product => product, (category, product) => (category, product.ProductName));
        }

0 Answers0