AJH.CMS.Core.Data.CategoryDataMapper.GetCategoryById C# (CSharp) Method

GetCategoryById() static private method

static private GetCategoryById ( int CategoryID ) : Category
CategoryID int
return AJH.CMS.Core.Entities.Category
        internal static Category GetCategoryById(int CategoryID)
        {
            Category category = null;

            using (SqlConnection sqlConnection = new SqlConnection(CMSCoreBase.CMSCoreConnectionString))
            {
                SqlCommand sqlCommand = new SqlCommand(SN_CATEGORY_GET_BY_ID, sqlConnection);
                sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;

                SqlParameter parameter = new SqlParameter(PN_CATEGORY_ID, System.Data.SqlDbType.Int);
                parameter.Direction = System.Data.ParameterDirection.Input;
                parameter.Value = CategoryID;
                sqlCommand.Parameters.Add(parameter);

                sqlCommand.Connection.Open();
                using (SqlDataReader reader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                {
                    while (reader.Read())
                    {
                        if (category == null)
                            category = new Category();
                        FillFromReader(category, reader);
                    }
                    reader.Close();
                    sqlCommand.Connection.Close();
                }
            }
            return category;
        }