using System.Collections.Generic;
public static void Main()
List<ProdSize> size1 = new List<ProdSize>
new ProdSize { size = "M", stock =1 },
new ProdSize { size = "S", stock =0 },
List<ProdSize> size2 = new List<ProdSize>
new ProdSize { size = "M", stock =0 },
new ProdSize { size = "S", stock =1 },
List<ProdSize> size3 = new List<ProdSize>
new ProdSize { size = "M", stock =1 },
new ProdSize { size = "S", stock =1 },
List<Product> productList = new List<Product>
new Product { productRef = "A", sizes = size1 },
new Product { productRef = "B", sizes = size2 },
new Product { productRef = "C", sizes = size3 },
var FinalList = productList.SelectMany(x => x.sizes, (prodObj, Sizes) => new { prodObj.productRef, Sizes })
.Where(x => x.Sizes.size == "M" && x.Sizes.stock > 0)
ProductName = x.productRef,
foreach (var item in FinalList)
Console.WriteLine("ProductName: {0}", item.ProductName);
Console.WriteLine("Size: {0}", item.Size);
Console.WriteLine("Stock: {0}", item.Stock);
public string productRef { get; set; }
public int totalStock { get; set; }
public List<ProdSize> sizes { get; set; }
public int stock { get; set; }
public string size { get; set; }