public List <ProductCategoryDto> GetProductCategorys(int level = 0, int parentId = 0, string type = null) { Expression <Func <v_ProductCategory, bool> > expression = s => s.Status == 1; if (level != 0) { expression = expression.And(s => s.Level == level); } if (parentId != 0) { expression = expression.And(s => s.ParentID == parentId); } if (!string.IsNullOrEmpty(type)) { expression = expression.And(s => s.Type == type); } var models = _v_ProductCategoryDtoRepository.WhereSelect(expression, s => new ProductCategoryDto() { ProductCatID = s.ProductCatID, Name = s.Name, Level = s.Level, ParentID = s.ParentID, Type = s.Type }).ToList(); return(models); }