AJH.CMS.Core.Data.StyleDataMapper.GetStyleById C# (CSharp) Method

GetStyleById() static private method

static private GetStyleById ( int StyleID ) : Style
StyleID int
return AJH.CMS.Core.Entities.Style
        internal static Style GetStyleById(int StyleID)
        {
            Style style = null;

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

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

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