using System.Collections.Generic;
public static void Main(string[] args)
List<Customer> customers = new List<Customer>()
new Customer(){ID = Guid.NewGuid(), Age = 23, First = "Joe", Last = "Smith"},
new Customer(){ID = Guid.NewGuid(), Age = 34, First = "Kevin", Last = "Costner"},
new Customer(){ID = Guid.NewGuid(), Age = 23, First = "Sally", Last = "Smuthers"},
new Customer(){ID = Guid.NewGuid(), Age = 56, First = "Mary", Last = "Jane"},
new Customer(){ID = Guid.NewGuid(), Age = 48, First = "Jane", Last = "Kendall"},
new Customer(){ID = Guid.NewGuid(), Age = 34, First = "Eve", Last = "Shrimp"},
new Customer(){ID = Guid.NewGuid(), Age = 31, First = "Donna", Last = "Lynn"},
new Customer(){ID = Guid.NewGuid(), Age = 21, First = "Sarah", Last = "Spicer"},
List<Order> orders = new List<Order>()
new Order() {CustomerID = customers[0].ID, Description="Shoes", Price=150.23M, Quantity=1},
new Order() {CustomerID = customers[0].ID, Description="Phone", Price=130.25M, Quantity=1},
new Order() {CustomerID = customers[0].ID, Description="Jacket", Price=230.14M, Quantity=1},
new Order() {CustomerID = customers[1].ID, Description="Phone", Price=130.25M, Quantity=1},
new Order() {CustomerID = customers[1].ID, Description="Jacket", Price=230.14M, Quantity=1},
new Order() {CustomerID = customers[1].ID, Description="Pants", Price=70.56M, Quantity=1},
new Order() {CustomerID = customers[2].ID, Description="Jacket", Price=230.14M, Quantity=1},
new Order() {CustomerID = customers[2].ID, Description="Pants", Price=70.56M, Quantity=1},
new Order() {CustomerID = customers[2].ID, Description="Shirt", Price=49.99M, Quantity=1},
new Order() {CustomerID = customers[3].ID, Description="Pants", Price=70.56M, Quantity=1},
new Order() {CustomerID = customers[3].ID, Description="Shirt", Price=49.99M, Quantity=1},
new Order() {CustomerID = customers[3].ID, Description="Scarf", Price=23.69M, Quantity=1},
new Order() {CustomerID = customers[4].ID, Description="Shirt", Price=49.99M, Quantity=1},
new Order() {CustomerID = customers[4].ID, Description="Scarf", Price=23.69M, Quantity=1},
new Order() {CustomerID = customers[4].ID, Description="Car", Price=24200.15M, Quantity=1},
new Order() {CustomerID = customers[5].ID, Description="Scarf", Price=23.69M, Quantity=1},
new Order() {CustomerID = customers[5].ID, Description="Car", Price=24200.15M, Quantity=1},
new Order() {CustomerID = customers[5].ID, Description="Computer", Price=650.00M, Quantity=1},
new Order() {CustomerID = customers[6].ID, Description="Car", Price=24200.15M, Quantity=1},
new Order() {CustomerID = customers[6].ID, Description="Computer", Price=650.00M, Quantity=1},
new Order() {CustomerID = customers[6].ID, Description="Shoes", Price=150.23M, Quantity=1},
new Order() {CustomerID = customers[7].ID, Description="Computer", Price=650.00M, Quantity=1},
new Order() {CustomerID = customers[7].ID, Description="Jacket", Price=230.14M, Quantity=1},
new Order() {CustomerID = customers[7].ID, Description="Pants", Price=70.56M, Quantity=1},
var CustOrders = from c in customers
join o in orders on c.ID equals o.CustomerID
orderby c.Last ascending, o.Price descending
select new { c.First ,c.Last,o.Description, o.Price, o.Quantity} ;
var TotalOrders = from o in orders
var TotalOrders1 = from o in orders
var TotalOrders2= from o in orders
var TotalCost = from o in orders
var TotalOrder_age = from o in orders
join c in customers on o.CustomerID equals c.ID
var TotalOrder_age1 = from o in orders
join c in customers on o.CustomerID equals c.ID
var MostExpensive = (from o in orders
orderby o.Price descending
select new { o.Description, o.Price, o.Quantity }).Distinct().Take(3);
var LeastExpensive = (from o in orders
select new { o.Description, o.Price, o.Quantity }).Distinct().Take(3);
Console.WriteLine("Customers and orders sorted by last name:");
Console.WriteLine("-------------------------------------------");
foreach (var c in CustOrders)
Console.WriteLine(c.First + " " + c.Last+"\n");
Console.WriteLine(c.Description + " " + c.Price + " " + c.Quantity);
Console.WriteLine("-------------------------------------------");
Console.WriteLine("Total Number of Orders: {0}\n",TotalOrders.Count());
Console.WriteLine("Total Number of Orders under $500: {0}\n", TotalOrders1.Count());
Console.WriteLine("Total Number of Orders over $500: {0}\n", TotalOrders2.Count());
Console.WriteLine("Total Number of Orders over $500: {0}\n", TotalCost.Sum());
Console.WriteLine("Total cost for all orders for people 30 or under: {0}\n",TotalOrder_age.Sum());
Console.WriteLine("Total cost for all orders for people over 30: {0}\n", TotalOrder_age1.Sum());
Console.WriteLine("-------------------------------------------");
Console.WriteLine("The Least Expensive Products:");
Console.WriteLine("-------------------------------------------");
foreach (var l in LeastExpensive)
Console.WriteLine(l.Description+" "+ l.Price+" "+l.Quantity );
Console.WriteLine("-------------------------------------------");
Console.WriteLine("The Most Expensive Products:");
Console.WriteLine("-------------------------------------------");
foreach(var e in MostExpensive)
Console.WriteLine(e.Description + " "+ e.Price+" "+e.Quantity);
Console.WriteLine("-------------------------------------------");
public Guid ID { get; set; }
public int Age { get; set; }
public string First { get; set; }
public string Last { get; set; }
public Guid CustomerID { get; set; }
public string Description { get; set; }
public decimal Price { get; set; }
public int Quantity { get; set; }