コード例 #1
0
        public static void TestDaoClass(NorthwindEntities context, Customer customer)
        {
            NorthwindDao.AddCustomer(context, customer);
            Customer addedCustomer = NorthwindDao.FindCustomerById(context, customer.CustomerID);

            Console.WriteLine("Added customer:");

            PrintCustomerInformation(addedCustomer);

            customer.ContactTitle = "UPDATED TITLE";

            NorthwindDao.EditCustomer(context, customer);
            Customer updatedCustomer = NorthwindDao.FindCustomerById(context, customer.CustomerID);

            Console.WriteLine("Updated customer:");

            PrintCustomerInformation(updatedCustomer);

            NorthwindDao.DeleteCustomer(context, customer);
            Customer deletedCustomer = NorthwindDao.FindCustomerById(context, customer.CustomerID);

            Console.WriteLine("Deleted customer:");

            PrintCustomerInformation(deletedCustomer);
        }
コード例 #2
0
        public static void FilterOrdersByYearAndDestinationWithSqlQuery(NorthwindEntities context)
        {
            IEnumerable <Customer> filteredCustomersByQuery =
                NorthwindDao.FindCustomersWithSpecialOrdersWithSqlQuery(context, 1997, "Canada");

            Console.WriteLine("\n*************************************************************\n");
            Console.WriteLine("Customers with orders made in 1997 and shipped to Canada With SQL:");
            foreach (var currentCustomer in filteredCustomersByQuery)
            {
                PrintCustomerInformation(currentCustomer);
            }
        }
コード例 #3
0
        public static void FilterSalesByRegionAndperiod(NorthwindEntities context)
        {
            Console.WriteLine("\n*************************************************************\n");
            Console.WriteLine("Sales by region and period:");
            DateTime            startDate     = new DateTime(1998, 1, 1, 0, 0, 0);
            DateTime            endDate       = DateTime.Now;
            IEnumerable <Order> filteredSales = NorthwindDao.FindSalesByRegionInPerion(context, "RJ", startDate, endDate);

            foreach (var order in filteredSales)
            {
                PrintOrderInformation(order);
            }

            Console.WriteLine("\n*************************************************************\n");
        }