/// <summary> /// 查找类目,找不到时返回null /// </summary> /// <param name="categoryId">类目Id</param> /// <returns></returns> public virtual ProductCategory GetCategory(long categoryId) { return(CategoryCache.GetOrCreate(categoryId, () => UnitOfWork.ReadData <ProductCategory, ProductCategory>(r => { var category = r.GetByIdWhereNotDeleted(categoryId); // 同时获取属性信息 if (category != null) { category.Properties.ToList(); category.Properties.SelectMany(p => p.PropertyValues).ToList(); } return category; }), CategoryCacheTime)); }
/// <summary> /// 查找类目,找不到时返回null /// </summary> /// <param name="categoryId">类目Id</param> /// <returns></returns> public virtual ProductCategory GetWithCache(Guid categoryId) { return(CategoryCache.GetOrCreate(categoryId, () => { using (UnitOfWork.Scope()) { var category = Get(categoryId); // 同时获取属性信息 if (category != null) { category.Properties.ToList(); category.Properties.SelectMany(p => p.PropertyValues).ToList(); } return category; } }, CategoryCacheTime)); }