/// <summary> /// Uses linq to find the first 5 products in the NorthWind class /// </summary> /// <param name="northWind">A NorthWind class</param> public static void First5Products(NorthWind northWind) { Console.WriteLine(""); Console.WriteLine("First 5 products"); //Write list with name of first 5 products northWind.Products().Take(5).ToList().ForEach(x => WriteLineLock(x.ProductName)); }
/// <summary> /// Instantiating Respiratory and NorthWind classes to use in solutions. /// And runs solutions. /// </summary> /// <param name="args"></param> static void Main(string[] args) { Console.WriteLine("Attaching NORTHWND.MDF"); using (NORTHWNDEntities1 db = new NORTHWNDEntities1()) { Console.WriteLine("Connecting NORTHWND.MDF"); db.Database.Connection.Open(); Console.WriteLine("Connected"); Respiratory respiratory = new Respiratory(db); NorthWind northWind = new NorthWind(respiratory); Console.WriteLine("Preparing database meta data"); //Dummy query northWind.Products().Take(0); Console.WriteLine("Ready"); // ReportingModule reportingModule = new ReportingModule(northWind); //IList<OrdersByTotalPriceDto> reportedOrders = reportingModule.TopOrdersByTotalPrice(5).Data; northWind.newOrderEvent += subscription; Console.WriteLine("Adding an order to Denmark."); northWind.AddOrder(DateTime.Now, "testName", "testAddress", "testCity", "testRegion", "2300", "Denmark"); //Write list with name of first 5 products First5Products(northWind); //Write the counting of orders by shipping country. Order the output by descending count [use LINQ] OrdersByShippingCountry(northWind); Console.WriteLine("Finished"); Console.ReadLine(); } }