예제 #1
0
        public List <Category> GetCategories(bool includeHiddenCategories)
        {
            // This is correct, but there's a bug in ES that doesn't honor the DNN Object Qualifier for M2M collections :(
            //List<Category> categories = this.UpToCategoryCollection;
            //if (!includeHiddenCategories)
            //{
            //    categories.RemoveAll(c => !c.IsDisplayed.GetValueOrDefault());
            //}
            //return categories;

            //SELECT
            //c.*
            //FROM DNNspot_Store_Category c
            //INNER JOIN DNNspot_Store_ProductCategory pc ON pc.CategoryId = c.Id
            //WHERE pc.ProductId = 21

            CategoryQuery        c  = new CategoryQuery("c");
            ProductCategoryQuery pc = new ProductCategoryQuery("pc");

            c.Select(c).InnerJoin(pc).On(c.Id == pc.CategoryId);
            c.Where(pc.ProductId == this.Id.Value);

            CategoryCollection collection = new CategoryCollection();

            collection.Load(c);

            return(collection.ToList());
        }
예제 #2
0
        public static short GetNextSortOrder(int storeId)
        {
            //SELECT
            //MAX(SortOrder)
            //FROM DNNspot_Store_Category
            //WHERE StoreId = 1

            var q = new CategoryQuery();

            q.es.Top = 1;
            q.Select(q.SortOrder.Max().As("MaxSortValue")).Where(q.StoreId == storeId);

            var x = new Category();

            if (x.Load(q))
            {
                short next = WA.Parser.ToShort(x.GetColumn("MaxSortValue")).Value;
                return((short)(next + 1));
            }
            return(9999);
        }