using System.Collections.Generic;
public static void Main(string[] args)
var productAId = Guid.NewGuid();
var productBId = Guid.NewGuid();
var customers = new List<Customer>
new Customer {Id = Guid.NewGuid(), Gender="F", LastName = "Adams", Age = 50, ProductId=productAId},
new Customer {Id = Guid.NewGuid(), Gender="M", LastName = "Jones", Age = 10, ProductId=productAId},
new Customer {Id = Guid.NewGuid(), Gender="M", LastName = "Hills", Age = 17, ProductId=productBId},
new Customer {Id = Guid.Empty, LastName = string.Empty, Age = 0},
new Customer {Id = Guid.NewGuid(), Gender="F", LastName = "Smith", Age = 15, ProductId=productAId}
var products = new List<Product>
new Product {Id = productBId, Name="ProdB", Description = "Product B"},
new Product {Id = productAId, Name="ProdA", Description = "Product B"}
var coreDemographic = from cust in customers where cust.Age < 18 && cust.ProductId != null && cust.Id != Guid.Empty group cust by cust.Gender into genderGroup orderby genderGroup.Key select genderGroup;
foreach( var c in coreDemographic)
Console.Write(c.Key + " ");
foreach (var person in c)
Console.Write(person.LastName);
public Guid Id { get; set; }
public string LastName { get; set; }
public int Age { get; set; }
public string Gender {get; set;}
public Guid? ProductId {get; set;}
public Guid Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }