AJH.CMS.Core.Data.FormRoleDataMapper.GetFormRoleById C# (CSharp) Method

GetFormRoleById() static private method

static private GetFormRoleById ( int ID ) : FormRole
ID int
return AJH.CMS.Core.Entities.FormRole
        internal static FormRole GetFormRoleById(int ID)
        {
            FormRole formRole = null;

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

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

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