private bool AddColumnSchema(XmlNameTable nameTable, DataColumn col, XmlNodeIdHashtable columns) { string array = XmlConvert.EncodeLocalName(col.ColumnName); string localName = nameTable.Get(array); if (localName == null) { localName = nameTable.Add(array); } col.encodedColumnName = localName; string namespaceURI = nameTable.Get(col.Namespace); if (namespaceURI == null) { namespaceURI = nameTable.Add(col.Namespace); } else if (col._columnUri != null) { col._columnUri = namespaceURI; } XmlNodeIdentety identety = new XmlNodeIdentety(localName, namespaceURI); columns[identety] = col; if (col.ColumnName.StartsWith("xml", StringComparison.OrdinalIgnoreCase)) { this.HandleSpecialColumn(col, nameTable, columns); } return true; }
private void HandleSpecialColumn(DataColumn col, XmlNameTable nameTable, XmlNodeIdHashtable columns) { // if column name starts with xml, we encode it manualy and add it for look up Debug.Assert(col.ColumnName.StartsWith("xml", StringComparison.OrdinalIgnoreCase), "column name should start with xml"); string tempColumnName; if ('x' == col.ColumnName[0]) { tempColumnName = "_x0078_"; // lower case xml... -> _x0078_ml... } else { tempColumnName = "_x0058_"; // upper case Xml... -> _x0058_ml... } tempColumnName = string.Concat(tempColumnName, col.ColumnName.AsSpan(1)); if (nameTable.Get(tempColumnName) == null) { nameTable.Add(tempColumnName); } string? columnNamespace = nameTable.Get(col.Namespace); XmlNodeIdentety idColumn = new XmlNodeIdentety(tempColumnName, columnNamespace); columns[idColumn] = col; }
private bool AddColumnSchema(XmlNameTable nameTable, DataColumn col, XmlNodeIdHashtable columns) { string _columnLocalName = XmlConvert.EncodeName(col.ColumnName); string columnLocalName = nameTable.Get(_columnLocalName); if (columnLocalName == null) { columnLocalName = nameTable.Add(_columnLocalName); } col.encodedColumnName = columnLocalName; string columnNamespace = nameTable.Get(col.Namespace); if (columnNamespace == null) { columnNamespace = nameTable.Add(col.Namespace); } else { if (col._columnUri != null) { col._columnUri = columnNamespace; } } XmlNodeIdentety idColumn = new XmlNodeIdentety(columnLocalName, columnNamespace); columns[idColumn] = col; return(true); }
private static bool AddColumnSchema(XmlNameTable nameTable, DataColumn col, XmlNodeIdHashtable columns) { string _columnLocalName = XmlConvert.EncodeLocalName(col.ColumnName); string columnLocalName = nameTable.Get(_columnLocalName) ?? // Look it up in a name table nameTable.Add(_columnLocalName); // Not found? Add it col._encodedColumnName = columnLocalName; // And set it back string?columnNamespace = nameTable.Get(col.Namespace); // Get column namespace from nametable if (columnNamespace == null) { // Not found ? columnNamespace = nameTable.Add(col.Namespace); // Add it } else { if (col._columnUri != null) // Update namespace { col._columnUri = columnNamespace; } } // Create XmlNodeIdentety // for this column XmlNodeIdentety idColumn = new XmlNodeIdentety(columnLocalName, columnNamespace); columns[idColumn] = col; // And add it to hashtable if (col.ColumnName.StartsWith("xml", StringComparison.OrdinalIgnoreCase)) { HandleSpecialColumn(col, nameTable, columns); } return(true); }
public TableSchemaInfo(DataTable tableSchema) { this.TableSchema = tableSchema; this.ColumnsSchemaMap = new XmlNodeIdHashtable(tableSchema.Columns.Count); this.ChildTablesSchemaMap = new XmlNodeIdHashtable(tableSchema.ChildRelations.Count); }
private bool AddColumnSchema(XmlNameTable nameTable, DataColumn col, XmlNodeIdHashtable columns) { string array = XmlConvert.EncodeLocalName(col.ColumnName); string localName = nameTable.Get(array); if (localName == null) { localName = nameTable.Add(array); } col.encodedColumnName = localName; string namespaceURI = nameTable.Get(col.Namespace); if (namespaceURI == null) { namespaceURI = nameTable.Add(col.Namespace); } else if (col._columnUri != null) { col._columnUri = namespaceURI; } XmlNodeIdentety identety = new XmlNodeIdentety(localName, namespaceURI); columns[identety] = col; if (col.ColumnName.StartsWith("xml", StringComparison.OrdinalIgnoreCase)) { this.HandleSpecialColumn(col, nameTable, columns); } return(true); }
// This one is used while reading data with preloaded schema private void BuildIdentityMap(XmlNameTable nameTable, DataTable dataTable) { ArrayList tableList = GetSelfAndDescendants(dataTable); // Get list of tables we're loading // This includes our table and // related tables tree this.tableSchemaMap = new XmlNodeIdHashtable(tableList.Count); // Create hash table to hold all // tables to load. foreach (DataTable t in tableList) // For each table { TableSchemaInfo tableSchemaInfo = AddTableSchema(nameTable, t); // Create schema info if (tableSchemaInfo != null) { foreach (DataColumn c in t.Columns) // Add column information // don't include auto-generated PK, FK and any hidden columns to be part of mapping { if (IsMappedColumn(c)) { AddColumnSchema(nameTable, c, tableSchemaInfo.ColumnsSchemaMap); } } foreach (DataRelation r in t.ChildRelations) // Add nested tables information { if (r.Nested) // Is it nested? // don't include non nested tables // Handle namespaces and names as usuall { string _tableLocalName = XmlConvert.EncodeLocalName(r.ChildTable.TableName); string tableLocalName = nameTable.Get(_tableLocalName); if (tableLocalName == null) { tableLocalName = nameTable.Add(_tableLocalName); } string tableNamespace = nameTable.Get(r.ChildTable.Namespace); if (tableNamespace == null) { tableNamespace = nameTable.Add(r.ChildTable.Namespace); } XmlNodeIdentety idTable = new XmlNodeIdentety(tableLocalName, tableNamespace); tableSchemaInfo.ColumnsSchemaMap[idTable] = r.ChildTable; } } } } }
private void BuildIdentityMap(XmlNameTable nameTable, DataSet dataSet) { _tableSchemaMap = new XmlNodeIdHashtable(dataSet.Tables.Count); // This hash table contains // tables schemas as TableSchemaInfo objects // These objects holds reference to the table. // Hash tables with columns schema maps // and child tables schema maps string dsNamespace = nameTable.Get(dataSet.Namespace) ?? // Attempt to look up DataSet namespace in the name table nameTable.Add(dataSet.Namespace); // Found? Nope. Add it dataSet._namespaceURI = dsNamespace; // Set a DataSet namespace URI foreach (DataTable t in dataSet.Tables) { // For each table TableSchemaInfo tableSchemaInfo = AddTableSchema(nameTable, t); // Add table schema info to hash table if (tableSchemaInfo != null) { foreach (DataColumn c in t.Columns) { // Add column schema map // don't include auto-generated PK, FK and any hidden columns to be part of mapping if (IsMappedColumn(c)) { // If mapped column AddColumnSchema(nameTable, c, tableSchemaInfo.ColumnsSchemaMap); } // Add it to the map } // Add child nested tables to the schema foreach (DataRelation r in t.ChildRelations) { // Do we have a child tables ? if (r.Nested) { // Is it nested? // don't include non nested tables // Handle namespaces and names as usuall string _tableLocalName = XmlConvert.EncodeLocalName(r.ChildTable.TableName); string?tableLocalName = nameTable.Get(_tableLocalName) ?? nameTable.Add(_tableLocalName); string?tableNamespace = nameTable.Get(r.ChildTable.Namespace) ?? nameTable.Add(r.ChildTable.Namespace); XmlNodeIdentety idTable = new XmlNodeIdentety(tableLocalName, tableNamespace); tableSchemaInfo.ColumnsSchemaMap[idTable] = r.ChildTable; } } } } }
private bool AddColumnSchema(DataColumn col, XmlNameTable nameTable, XmlNodeIdHashtable columns) { string columnLocalName = nameTable.Get(col.EncodedColumnName); string columnNamespace = nameTable.Get(col.Namespace); if (columnLocalName == null) { return(false); } XmlNodeIdentety idColumn = new XmlNodeIdentety(columnLocalName, columnNamespace); columns[idColumn] = col; return(true); }
private void BuildIdentityMap(DataTable dataTable, XmlNameTable nameTable) { this.tableSchemaMap = new XmlNodeIdHashtable(1); TableSchemaInfo info = this.AddTableSchema(dataTable, nameTable); if (info != null) { foreach (DataColumn column in dataTable.Columns) { if (IsMappedColumn(column)) { this.AddColumnSchema(column, nameTable, info.ColumnsSchemaMap); } } } }
private bool AddColumnSchema(DataColumn col, XmlNameTable nameTable, XmlNodeIdHashtable columns) { string localName = nameTable.Get(col.EncodedColumnName); string namespaceURI = nameTable.Get(col.Namespace); if (localName == null) { return false; } XmlNodeIdentety identety = new XmlNodeIdentety(localName, namespaceURI); columns[identety] = col; if (col.ColumnName.StartsWith("xml", StringComparison.OrdinalIgnoreCase)) { this.HandleSpecialColumn(col, nameTable, columns); } return true; }
private bool AddColumnSchema(DataColumn col, XmlNameTable nameTable, XmlNodeIdHashtable columns) { string localName = nameTable.Get(col.EncodedColumnName); string namespaceURI = nameTable.Get(col.Namespace); if (localName == null) { return(false); } XmlNodeIdentety identety = new XmlNodeIdentety(localName, namespaceURI); columns[identety] = col; if (col.ColumnName.StartsWith("xml", StringComparison.OrdinalIgnoreCase)) { this.HandleSpecialColumn(col, nameTable, columns); } return(true); }
private void BuildIdentityMap(DataTable dataTable, XmlNameTable nameTable) { _tableSchemaMap = new XmlNodeIdHashtable(1); TableSchemaInfo?tableSchemaInfo = AddTableSchema(dataTable, nameTable); if (tableSchemaInfo != null) { foreach (DataColumn c in dataTable.Columns) { // don't include auto-generated PK, FK and any hidden columns to be part of mapping if (IsMappedColumn(c)) { AddColumnSchema(c, nameTable, tableSchemaInfo.ColumnsSchemaMap); } } } }
private void BuildIdentityMap(XmlNameTable nameTable, DataSet dataSet) { this.tableSchemaMap = new XmlNodeIdHashtable(dataSet.Tables.Count); string str3 = nameTable.Get(dataSet.Namespace); if (str3 == null) { str3 = nameTable.Add(dataSet.Namespace); } dataSet.namespaceURI = str3; foreach (DataTable table in dataSet.Tables) { TableSchemaInfo info = this.AddTableSchema(nameTable, table); if (info != null) { foreach (DataColumn column in table.Columns) { if (IsMappedColumn(column)) { this.AddColumnSchema(nameTable, column, info.ColumnsSchemaMap); } } foreach (DataRelation relation in table.ChildRelations) { if (relation.Nested) { string array = XmlConvert.EncodeLocalName(relation.ChildTable.TableName); string localName = nameTable.Get(array); if (localName == null) { localName = nameTable.Add(array); } string namespaceURI = nameTable.Get(relation.ChildTable.Namespace); if (namespaceURI == null) { namespaceURI = nameTable.Add(relation.ChildTable.Namespace); } XmlNodeIdentety identety = new XmlNodeIdentety(localName, namespaceURI); info.ColumnsSchemaMap[identety] = relation.ChildTable; } } } } }
private void BuildIdentityMap(DataSet dataSet, XmlNameTable nameTable) { this.tableSchemaMap = new XmlNodeIdHashtable(dataSet.Tables.Count); foreach (DataTable t in dataSet.Tables) { TableSchemaInfo tableSchemaInfo = AddTableSchema(t, nameTable); if (tableSchemaInfo != null) { foreach (DataColumn c in t.Columns) { // don't include auto-generated PK, FK and any hidden columns to be part of mapping if (IsMappedColumn(c)) { AddColumnSchema(c, nameTable, tableSchemaInfo.ColumnsSchemaMap); } } } } }
private bool AddChildTableSchema(XmlNameTable nameTable, DataRelation rel, XmlNodeIdHashtable childtables) { string _tableLocalName = XmlConvert.EncodeName(rel.ChildTable.TableName); string tableLocalName = nameTable.Get(_tableLocalName); if (tableLocalName == null) { tableLocalName = nameTable.Add(_tableLocalName); } string tableNamespace = nameTable.Get(rel.ChildTable.Namespace); if (tableNamespace == null) { tableNamespace = nameTable.Add(rel.ChildTable.Namespace); } XmlNodeIdentety idTable = new XmlNodeIdentety(tableLocalName, tableNamespace); childtables[idTable] = rel; return(true); }
private void HandleSpecialColumn(DataColumn col, XmlNameTable nameTable, XmlNodeIdHashtable columns) { string str; if ('x' == col.ColumnName[0]) { str = "_x0078_"; } else { str = "_x0058_"; } str = str + col.ColumnName.Substring(1); if (nameTable.Get(str) == null) { nameTable.Add(str); } string namespaceURI = nameTable.Get(col.Namespace); XmlNodeIdentety identety = new XmlNodeIdentety(str, namespaceURI); columns[identety] = col; }
private void BuildIdentityMap(XmlNameTable nameTable, DataSet dataSet) { this.tableSchemaMap = new XmlNodeIdHashtable(dataSet.Tables.Count); string dsNamespace = nameTable.Get(dataSet.Namespace); if (dsNamespace == null) { dsNamespace = nameTable.Add(dataSet.Namespace); } dataSet.namespaceURI = dsNamespace; foreach (DataTable t in dataSet.Tables) { TableSchemaInfo tableSchemaInfo = AddTableSchema(nameTable, t); if (tableSchemaInfo != null) { foreach (DataColumn c in t.Columns) { // don't include auto-generated PK, FK and any hidden columns to be part of mapping if (IsMappedColumn(c)) { AddColumnSchema(nameTable, c, tableSchemaInfo.ColumnsSchemaMap); } } foreach (DataRelation r in t.ChildRelations) { if (r.Nested) { // don't include non nested tables AddChildTableSchema(nameTable, r, tableSchemaInfo.ChildTablesSchemaMap); } } } } }
private bool AddColumnSchema(XmlNameTable nameTable, DataColumn col, XmlNodeIdHashtable columns) { string _columnLocalName = XmlConvert.EncodeLocalName(col.ColumnName); string columnLocalName = nameTable.Get(_columnLocalName); // Look it up in a name table if (columnLocalName == null) { // Not found? columnLocalName = nameTable.Add(_columnLocalName); // Add it } col._encodedColumnName = columnLocalName; // And set it back string columnNamespace = nameTable.Get(col.Namespace); // Get column namespace from nametable if (columnNamespace == null) { // Not found ? columnNamespace = nameTable.Add(col.Namespace); // Add it } else { if (col._columnUri != null) // Update namespace col._columnUri = columnNamespace; } // Create XmlNodeIdentety // for this column XmlNodeIdentety idColumn = new XmlNodeIdentety(columnLocalName, columnNamespace); columns[idColumn] = col; // And add it to hashtable if (col.ColumnName.StartsWith("xml", StringComparison.OrdinalIgnoreCase)) { HandleSpecialColumn(col, nameTable, columns); } return true; }
public TableSchemaInfo(DataTable tableSchema) { TableSchema = tableSchema; ColumnsSchemaMap = new XmlNodeIdHashtable(tableSchema.Columns.Count); }
private void HandleSpecialColumn(DataColumn col, XmlNameTable nameTable, XmlNodeIdHashtable columns) { // if column name starts with xml, we encode it manualy and add it for look up Debug.Assert(col.ColumnName.StartsWith("xml", StringComparison.OrdinalIgnoreCase), "column name should start with xml"); string tempColumnName; if ('x' == col.ColumnName[0]) { tempColumnName = "_x0078_"; // lower case xml... -> _x0078_ml... } else { tempColumnName = "_x0058_"; // upper case Xml... -> _x0058_ml... } tempColumnName += col.ColumnName.Substring(1); if (nameTable.Get(tempColumnName) == null) { nameTable.Add(tempColumnName); } string columnNamespace = nameTable.Get(col.Namespace); XmlNodeIdentety idColumn = new XmlNodeIdentety(tempColumnName, columnNamespace); columns[idColumn] = col; }
// This one is used while reading data with preloaded schema private void BuildIdentityMap(XmlNameTable nameTable, DataTable dataTable) { ArrayList tableList = GetSelfAndDescendants(dataTable); // Get list of tables we're loading // This includes our table and // related tables tree _tableSchemaMap = new XmlNodeIdHashtable(tableList.Count); // Create hash table to hold all // tables to load. foreach (DataTable t in tableList) { // For each table TableSchemaInfo tableSchemaInfo = AddTableSchema(nameTable, t); // Create schema info if (tableSchemaInfo != null) { foreach (DataColumn c in t.Columns) { // Add column information // don't include auto-generated PK, FK and any hidden columns to be part of mapping if (IsMappedColumn(c)) { AddColumnSchema(nameTable, c, tableSchemaInfo.ColumnsSchemaMap); } } foreach (DataRelation r in t.ChildRelations) { // Add nested tables information if (r.Nested) { // Is it nested? // don't include non nested tables // Handle namespaces and names as usuall string _tableLocalName = XmlConvert.EncodeLocalName(r.ChildTable.TableName); string tableLocalName = nameTable.Get(_tableLocalName); if (tableLocalName == null) { tableLocalName = nameTable.Add(_tableLocalName); } string tableNamespace = nameTable.Get(r.ChildTable.Namespace); if (tableNamespace == null) { tableNamespace = nameTable.Add(r.ChildTable.Namespace); } XmlNodeIdentety idTable = new XmlNodeIdentety(tableLocalName, tableNamespace); tableSchemaInfo.ColumnsSchemaMap[idTable] = r.ChildTable; } } } } }
// Used for inference private void BuildIdentityMap(DataTable dataTable, XmlNameTable nameTable) { _tableSchemaMap = new XmlNodeIdHashtable(1); TableSchemaInfo tableSchemaInfo = AddTableSchema(dataTable, nameTable); if (tableSchemaInfo != null) { foreach (DataColumn c in dataTable.Columns) { // don't include auto-generated PK, FK and any hidden columns to be part of mapping if (IsMappedColumn(c)) { AddColumnSchema(c, nameTable, tableSchemaInfo.ColumnsSchemaMap); } } } }
private void BuildIdentityMap(XmlNameTable nameTable, DataTable dataTable) { ArrayList selfAndDescendants = this.GetSelfAndDescendants(dataTable); this.tableSchemaMap = new XmlNodeIdHashtable(selfAndDescendants.Count); foreach (DataTable table in selfAndDescendants) { TableSchemaInfo info = this.AddTableSchema(nameTable, table); if (info != null) { foreach (DataColumn column in table.Columns) { if (IsMappedColumn(column)) { this.AddColumnSchema(nameTable, column, info.ColumnsSchemaMap); } } foreach (DataRelation relation in table.ChildRelations) { if (relation.Nested) { string array = XmlConvert.EncodeLocalName(relation.ChildTable.TableName); string localName = nameTable.Get(array); if (localName == null) { localName = nameTable.Add(array); } string namespaceURI = nameTable.Get(relation.ChildTable.Namespace); if (namespaceURI == null) { namespaceURI = nameTable.Add(relation.ChildTable.Namespace); } XmlNodeIdentety identety = new XmlNodeIdentety(localName, namespaceURI); info.ColumnsSchemaMap[identety] = relation.ChildTable; } } } } }
// This one is used while reading data with preloaded schema private void BuildIdentityMap(XmlNameTable nameTable, DataSet dataSet) { _tableSchemaMap = new XmlNodeIdHashtable(dataSet.Tables.Count); // This hash table contains // tables schemas as TableSchemaInfo objects // These objects holds reference to the table. // Hash tables with columns schema maps // and child tables schema maps string dsNamespace = nameTable.Get(dataSet.Namespace); // Attept to look up DataSet namespace // in the name table if (dsNamespace == null) { // Found ? dsNamespace = nameTable.Add(dataSet.Namespace); // Nope. Add it } dataSet._namespaceURI = dsNamespace; // Set a DataSet namespace URI foreach (DataTable t in dataSet.Tables) { // For each table TableSchemaInfo tableSchemaInfo = AddTableSchema(nameTable, t); // Add table schema info to hash table if (tableSchemaInfo != null) { foreach (DataColumn c in t.Columns) { // Add column schema map // don't include auto-generated PK, FK and any hidden columns to be part of mapping if (IsMappedColumn(c)) { // If mapped column AddColumnSchema(nameTable, c, tableSchemaInfo.ColumnsSchemaMap); } // Add it to the map } // Add child nested tables to the schema foreach (DataRelation r in t.ChildRelations) { // Do we have a child tables ? if (r.Nested) { // Is it nested? // don't include non nested tables // Handle namespaces and names as usuall string _tableLocalName = XmlConvert.EncodeLocalName(r.ChildTable.TableName); string tableLocalName = nameTable.Get(_tableLocalName); if (tableLocalName == null) { tableLocalName = nameTable.Add(_tableLocalName); } string tableNamespace = nameTable.Get(r.ChildTable.Namespace); if (tableNamespace == null) { tableNamespace = nameTable.Add(r.ChildTable.Namespace); } XmlNodeIdentety idTable = new XmlNodeIdentety(tableLocalName, tableNamespace); tableSchemaInfo.ColumnsSchemaMap[idTable] = r.ChildTable; } } } } }