private static void PopulateMultiRow(XmlReader reader, string elementName, string elementNamespace, DataTable datatable, InlineErrorHandlingType inlineErrorHandling, int parentRowIndex) { DataColumn parentColumn = null; if (parentRowIndex >= 0 && datatable.Columns.Contains(datatable.TableName)) { parentColumn = datatable.Columns[datatable.TableName]; } while (reader.IsStartElement(elementName, elementNamespace)) { if (reader.IsEmptyElement) { reader.ReadStartElement(); DataRow row = RowsetFormatter.CreateNewRow(datatable, parentColumn, parentRowIndex); datatable.Rows.Add(row); } else { reader.ReadStartElement(); RowsetFormatter.PopulateRow(reader, datatable, inlineErrorHandling, parentRowIndex, parentColumn); reader.ReadEndElement(); } } FormattersHelpers.CheckException(reader); }
private static void PopulateRow(XmlReader reader, DataTable datatable, InlineErrorHandlingType inlineErrorHandling, int parentRowIndex, DataColumn parentColumn) { DataRow dataRow = RowsetFormatter.CreateNewRow(datatable, parentColumn, parentRowIndex); while (reader.IsStartElement()) { FormattersHelpers.CheckException(reader); if (!FormattersHelpers.IsNullContentElement(reader)) { string localName = reader.LocalName; DataColumn dataColumn = datatable.Columns[localName]; if (dataColumn == null) { throw new AdomdUnknownResponseException(XmlaSR.UnknownServerResponseFormat, string.Format(CultureInfo.InvariantCulture, "Unknown column {0}", new object[] { localName })); } string columnNamespace = FormattersHelpers.GetColumnNamespace(dataColumn); if (reader.NamespaceURI == columnNamespace) { if (RowsetFormatter.IsNestedColumn(dataColumn)) { DataTable dataTable = RowsetFormatter.FindNestedTable(dataColumn); if (dataTable != null) { RowsetFormatter.PopulateMultiRow(reader, localName, columnNamespace, dataTable, inlineErrorHandling, (int)dataRow[dataColumn]); } else { reader.Skip(); } } else { Type elementType = FormattersHelpers.GetElementType(reader, "http://www.w3.org/2001/XMLSchema-instance", dataColumn); bool throwOnInlineError = inlineErrorHandling == InlineErrorHandlingType.Throw; object obj = FormattersHelpers.ReadRowsetProperty(reader, localName, columnNamespace, elementType, throwOnInlineError, elementType.IsArray && FormattersHelpers.GetColumnXsdTypeName(dataColumn) != "base64Binary", FormattersHelpers.GetConvertToLocalTime(dataColumn)); if (inlineErrorHandling == InlineErrorHandlingType.StoreInErrorsCollection) { XmlaError xmlaError = obj as XmlaError; if (xmlaError == null) { dataRow[localName] = obj; } else { dataRow.SetColumnError(localName, xmlaError.Description); } } else { dataRow[localName] = obj; } } } else { reader.Skip(); } } else { reader.Skip(); } } datatable.Rows.Add(dataRow); }