예제 #1
0
        public List <Product> GetRelatedProducts()
        {
            ProductQuery        p  = new ProductQuery("p");
            RelatedProductQuery rp = new RelatedProductQuery("rp");

            p.Select(p).InnerJoin(rp).On(p.Id == rp.RelatedProductId);
            p.Where(rp.ProductId == this.Id.Value);

            ProductCollection collection = new ProductCollection();

            collection.Load(p);

            return(collection.ToList());
        }
예제 #2
0
        /// <summary>
        /// Get the Product entities associated with this order's order items.
        /// If products were deleted since the order was placed, this product count
        /// will not match the order item count.
        /// </summary>
        /// <returns></returns>
        public List <Product> GetOrderItemProducts()
        {
            List <OrderItem> orderItems = this.OrderItemCollectionByOrderId.ToList();
            List <int>       productIds = orderItems.ConvertAll(oi => oi.ProductId.Value);

            ProductQuery q = new ProductQuery();

            q.Where(q.Id.In(productIds.ToArray()));

            ProductCollection collection = new ProductCollection();

            collection.Load(q);

            return(collection.ToList());
        }
예제 #3
0
        public static List <Product> GetAll(int storeId, bool includeActiveProductsOnly)
        {
            ProductQuery q = new ProductQuery();

            q.Where(q.StoreId == storeId);
            if (includeActiveProductsOnly)
            {
                q.Where(q.IsActive == true);
            }
            q.OrderBy(q.Name.Ascending);

            ProductCollection collection = new ProductCollection();

            collection.Load(q);

            return(collection.ToList());
        }