AJH.CMS.Core.Data.CMSControlDataMapper.GetCMSControlById C# (CSharp) Method

GetCMSControlById() static private method

static private GetCMSControlById ( int CMSControlID ) : CMSControl
CMSControlID int
return AJH.CMS.Core.Entities.CMSControl
        internal static CMSControl GetCMSControlById(int CMSControlID)
        {
            CMSControl cmsControl = null;

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

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

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