using System.Collections.Generic;
public static void Main()
List<Category> listCategories = new List<Category>
Id = 1, CateName = "SmartPhone"
Id = 2, CateName = "Laptop"
Id = 3, CateName = "Desktop"
List<Product> listProducts = new List<Product>
Id = 1, ProdName = "Lumia 720", CategoryId = 1
Id = 2, ProdName = "PC HP", CategoryId = 3
Id = 3, ProdName = "PC Dell", CategoryId = 3
join c in listCategories on p.CategoryId equals c.Id into e
from j in e.DefaultIfEmpty()group p by new
Products = g.ToList(), CategoryId = g.Key.Id, CateogryName = g.Key.CateName
foreach (var item in query)
Console.WriteLine("CategoryName: {0}", item.CateogryName);
foreach(var product in item.Products)
Console.WriteLine("Product: {0}", product.ProdName);
public string CateogryName
public List<Product> Products