Esempio n. 1
0
        static void BuggyShowQuesoCabralesOrders()
        {
            Console.WriteLine("\nBuggyShowQuesoCabralesOrders\n");

            try
            {
                IQueryLite <OrderDetail> orderDetailSubQuery = ds.OrderDetailRepository.Query(Projection.BaseTable)
                                                               .Fields(OrderDetailFields.OrderId)
                                                               .Where(OrderDetailFields.ProductId, 11);

                // SELECT OrderId, OrderDate, CustomerId
                // FROM dbo.Orders
                // WHERE OrderId IN (
                //       SELECT OrderId
                //       FROM dbo.OrderDetails
                //       WHERE ProductId = 11
                //    )
                IQueryLite <Order> orderQuery = ds.OrderRepository.Query(Projection.BaseTable)
                                                .Fields(OrderFields.OrderId, OrderFields.OrderDate, OrderFields.CustomerId)
                                                .Where(OrderFields.OrderId, OperatorLite.In, orderDetailSubQuery);

                foreach (var order in orderQuery.ToEnumerable())
                {
                    Console.WriteLine("OrderId {0}, OrderDate {1}, CustomerId {2}",
                                      order.OrderId, order.OrderDate, order.CustomerId);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 2
0
        static void ShowQuesoCabralesOrders()
        {
            Console.WriteLine("\nShowQuesoCabralesOrders\n");

            IQueryLite <OrderDetail> orderDetailSubQuery = ds.OrderDetailRepository.Query(Projection.BaseTable)
                                                           .Fields(FieldsOption.None, OrderDetailFields.OrderId)
                                                           .Where(OrderDetailFields.ProductId, 11);

            var orderIds = orderDetailSubQuery.ToEnumerable().Select(x => x.OrderId).ToList();

            // SELECT OrderId, OrderDate, CustomerId
            // FROM dbo.Orders
            // WHERE OrderId IN (
            //       SELECT OrderId
            //       FROM dbo.OrderDetails
            //       WHERE ProductId = 11
            //    )
            //IQueryLite<Order> orderQuery = ds.OrderRepository.Query(Projection.BaseTable)
            //    .Fields(OrderFields.OrderId, OrderFields.OrderDate, OrderFields.CustomerId)
            //    .Where(OrderFields.OrderId, OperatorLite.In, orderDetailSubQuery);

            IQueryLite <Order> orderQuery = ds.OrderRepository.Query(Projection.BaseTable)
                                            .Fields(OrderFields.OrderId, OrderFields.OrderDate, OrderFields.CustomerId)
                                            .Where(OrderFields.OrderId, OperatorLite.In, orderIds);

            foreach (var order in orderQuery.ToEnumerable())
            {
                Console.WriteLine("OrderId {0}, OrderDate {1}, CustomerId {2}",
                                  order.OrderId, order.OrderDate, order.CustomerId);
            }
        }