public long GetOrdersByCustomer(string id)
        {
            Stopwatch clock = new Stopwatch();

            clock.Start();
            List <Order> customerOrders;

            using (IDbConnection db = new SqlConnection(connString))
            {
                customerOrders = db.Query <Order, Customer, Order>(Constants.GET_CUSTOMERS_ORDER,
                                                                   (order, customer) =>
                {
                    order.Customer = customer;
                    return(order);
                },
                                                                   new { CustomerID = id },
                                                                   splitOn: "CustomerID").ToList();
            }
            clock.Stop();
            var elapsedTime = clock.ElapsedMilliseconds;

            ResultComparer.GetOrdersByCustomer(customerOrders, method);

            return(elapsedTime);
        }
Пример #2
0
        public long GetOrdersByCustomer(string customerId)
        {
            Stopwatch clock = new Stopwatch();

            clock.Start();
            var query = from order in db.Orders
                        join customer in db.Customers on order.CustomerID equals customer.CustomerID
                        where customer.CustomerID == customerId
                        select order;

            query.ToList();
            clock.Stop();
            var elapsedTime = clock.ElapsedMilliseconds;

            ResultComparer.GetOrdersByCustomer(query.ToList(), method);
            return(elapsedTime);
        }
        public long GetOrdersByCustomer(string customerId)
        {
            Stopwatch clock = new Stopwatch();

            clock.Start();
            List <Order> result;

            using (NwEntityContext context = new NwEntityContext())
            {
                result = context.Orders.Include(x => x.Customer).Include(x => x.Customer).Where(x => x.Customer.CustomerID == customerId).ToList();
            }
            clock.Stop();
            var elapsedTime = clock.ElapsedMilliseconds;

            ResultComparer.GetOrdersByCustomer(result, method);

            return(elapsedTime);
        }