internal object ParseRelatedRecords(RelatedEntityQueryBuilder schema)
        {
            var sampleDataSet = new DataSet { Locale = CultureInfo.InvariantCulture };
            DataTable output = sampleDataSet.Tables.Add("Related Entities");

            SetTableColumnsFromSchema(schema, output);

            output.Columns.Add("Updated", typeof(bool));

            foreach (var response in _response.Entities)
            {
                var row = output.NewRow();
                ParseResponseUsingSchema(schema, row, response);
                output.Rows.Add(row);
            }

            output.AcceptChanges();
            return output;
        }
        private void QueryRelatedRecords()
        {
            WorkAsync("Querying Related Entities for Selected Row from Step 4",
                e => // Work To Do Asynchronously
                {
                    var fetchXmlBuilder = new RelatedEntityQueryBuilder();
                    var formEntryReader = new FormEntryReader(fetchXmlBuilder);
                    formEntryReader.ReadEntitySelected(entityDropdown);
                    formEntryReader.ReadUniqueIdentifierAttributes(entityAttributeView);
                    formEntryReader.ReadFilterValuesFromSelectedRow(duplicatesGrid);
                    formEntryReader.ReadRelatedEntitySelected(relationShipDropdown);
                    fetchXmlBuilder.AddColumn(new CrmEntityAttribute("createdon", "DateTime"));
                    var response = GetRecordsFromCrm(fetchXmlBuilder.GetOutput());

                    var reader = new FetchXmlResponseReader(response);
                    var dataset = reader.ParseRelatedRecords(fetchXmlBuilder);
                    SafeSetDataSource(relatedEntityGrid, dataset);

                    e.Result = "Step 6 Record View Updated";
                }, e =>
                {
                    MessageBox.Show(e.Result as string);
                });
        }