Пример #1
0
        /// <summary>
        /// Instantiating Respiratory and NorthWind classes to use in solutions.
        /// And runs solutions.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            //Which Respiratory should we use?
            Console.WriteLine("Which respiratory would you like to use? Write 0 for CSV and 1 for DBMS.");
            int respiratoryIndex = 0;
            if (!int.TryParse(Console.ReadLine(), out respiratoryIndex) && respiratoryIndex != 0 && respiratoryIndex != 1)
            {
                Console.WriteLine("Tou did not write a legit input. Program will not exit!");
                return;
            }
            IRespiratory respiratory = null;
            switch (respiratoryIndex)
            {
                case 0:
                    Console.WriteLine("CSV respiratory chosen");
                    Console.WriteLine("Loading CSV...");
                    respiratory = CSVimporter.ImportCSV(Resources.categories, Resources.products, Resources.orders, Resources.order_details);
                    Console.WriteLine("Loaded");
                    break;
                case 1:
                    Console.WriteLine("DBMS respiratory chosen");
                    Console.WriteLine("Attaching NORTHWND.MDF");
                    NORTHWNDEntities2 db = new NORTHWNDEntities2();
                        Console.WriteLine("Connecting NORTHWND.MDF");
                        db.Database.Connection.Open();
                        respiratory = new DBMSRespiratory(db);
                        Console.WriteLine("Connected");
                    break;
            }
            INorthWind 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();
        }
Пример #2
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="context">Entity-Framework NORTHWNDEntities1 dataContext</param>
 public DBMSRespiratory(NORTHWNDEntities2 context)
 {
     this.context = context;
 }