Example #1
0
        /// <summary>
        /// 导航面板查询
        /// </summary>
        /// <param name="criteria"></param>
        protected EntityList FetchBy(ProductNavigationCriteria criteria)
        {
            return(this.QueryList(q =>
            {
                //q.JoinRef(Product.ProductCategoryIdProperty));

                //if (criteria.IncludeSub)
                //{
                //    q.Constrain(ProductCategory.TreeIndexProperty).StartWith(criteria.ProductCategory.TreeCode);
                //}
                //else
                //{
                //    q.Constrain(ProductCategory.TreeIndexProperty).Equal(criteria.ProductCategory.TreeCode);
                //}

                q.Constrain(Product.ProductCategoryIdProperty).Equal(criteria.ProductCategoryId);

                if (criteria.IncludeSub)
                {
                    criteria.ProductCategory.TreeChildren.EachNode(child =>
                    {
                        q.Or().Constrain(Product.ProductCategoryIdProperty).Equal(child.Id);
                        return false;
                    });
                }
            }));
        }
Example #2
0
        public virtual ProductList GetBy(ProductNavigationCriteria criteria)
        {
            var ids = new List <object>();

            ids.Add(criteria.ProductCategoryId);
            if (criteria.IncludeSub)
            {
                criteria.ProductCategory.TreeChildren.EachNode(child =>
                {
                    ids.Add(child.Id);
                    return(false);
                });
            }

            var q = this.CreateLinqQuery();

            q = q.Where(e => ids.Contains(e.ProductCategoryId));

            return((ProductList)this.QueryData(q));
        }