コード例 #1
0
        public List <Category> GetTopCategories()
        {
            List <Category>      categoriesList = new List <Category>();
            _executerCategoryCmd executer       = new _executerCategoryCmd(ExecuteCategorySqlCmd);

            using (SqlConnection sqlConnection = new SqlConnection(_connectionString))
            {
                using (SqlCommand cmd = new SqlCommand("GetTopCategories", sqlConnection))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    categoriesList  = executer(sqlConnection, cmd);
                }
            }

            return(categoriesList);
        }
コード例 #2
0
        public List <Category> GetChildCategoriesById(int categoryId)
        {
            List <Category> categoriesList = new List <Category>();

            if (categoryId > 0)
            {
                _executerCategoryCmd executer = new _executerCategoryCmd(ExecuteCategorySqlCmd);

                using (SqlConnection sqlConnection = new SqlConnection(_connectionString))
                {
                    using (SqlCommand cmd = new SqlCommand("GetChildCategoriesById", sqlConnection))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@CategoryId", categoryId);
                        categoriesList = executer(sqlConnection, cmd);
                    }
                }
            }

            return(categoriesList);
        }
コード例 #3
0
        public Category GetCategoryById(int categoryId)
        {
            Category category = new Category();

            if (categoryId > 0)
            {
                _executerCategoryCmd executer = new _executerCategoryCmd(ExecuteCategorySqlCmd);

                using (SqlConnection sqlConnection = new SqlConnection(_connectionString))
                {
                    using (SqlCommand cmd = new SqlCommand("GetCategoryById", sqlConnection))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@CategoryId", categoryId);
                        category = executer(sqlConnection, cmd).FirstOrDefault();
                    }
                }
            }

            return(category);
        }