public CategoryCollection GetMainCategories()
        {
            CategoryCollection categories = new CategoryCollection();
            PredicateExpression filter = new PredicateExpression();
            filter.Add(new FieldCompareNullPredicate(CategoryFields.BaseCategoryId));
            categories.GetMulti(filter);

            return categories;
        }
        public CategoryCollection GetMainCategories()
        {
            CategoryCollection  categories = new CategoryCollection();
            PredicateExpression filter     = new PredicateExpression();

            filter.Add(new FieldCompareNullPredicate(CategoryFields.BaseCategoryId));
            categories.GetMulti(filter);

            return(categories);
        }
        public CategoryCollection GetSubCategories(int mainCatId)
        {
            CategoryCollection  subCategories = new CategoryCollection();
            PredicateExpression filter        = new PredicateExpression();
            IPrefetchPath       prefetchPath  = new PrefetchPath((int)EntityType.CategoryEntity);

            prefetchPath.Add(CategoryEntity.PrefetchPathCategories);
            filter.Add(CategoryFields.BaseCategoryId == mainCatId);
            subCategories.GetMulti(filter, prefetchPath);

            return(subCategories);
        }
        public IList<Category> GetByAccount(long accountId, ref IAuctionTransaction trans)
        {
            using (var records = new CategoryCollection())
            {
                var filter = new PredicateExpression(CategoryFields.AccountId == accountId);

                if (trans != null)
                {
                    trans.Add(records);
                }
                records.GetMulti(filter, 0);
                return records.ToList().Select(c => new Category() { Id = c.Id, Name = c.Name, AccountId = c.AccountId }).ToList();
            }
        }
        public Category Get(long Id, ref IAuctionTransaction trans)
        {
            using (var records = new CategoryCollection())
            {
                var filter = new PredicateExpression(CategoryFields.Id == Id);

                if (trans != null)
                {
                    trans.Add(records);
                }
                records.GetMulti(filter, 1);
                var c = records.ToList().FirstOrDefault();
                return new Category() { Id = c.Id, Name = c.Name, AccountId =  c.AccountId};
            }
        }
        public CategoryCollection GetSubCategories(int mainCatId)
        {
            CategoryCollection subCategories = new CategoryCollection();
            PredicateExpression filter = new PredicateExpression();
            IPrefetchPath prefetchPath = new PrefetchPath((int)EntityType.CategoryEntity);
            prefetchPath.Add(CategoryEntity.PrefetchPathCategories);
            filter.Add(CategoryFields.BaseCategoryId == mainCatId);
            subCategories.GetMulti(filter, prefetchPath);

            return subCategories;
        }