System.Data Namespace
Contains a collection of ColumnMapping objects, and is implemented by the DataColumnMappingCollection, which is used in common by .NET data providers.
Visibility |
Name |
Value Type |
Accessibility |
public |
Item
( String
index )
|
Object |
[ Get , Set ] |
|
The IColumnMappingCollection interface allows an inheriting class to implement a ColumnMapping collection. For more information, see Setting Up DataTable and DataColumn Mappings.
An application does not create an instance of the IColumnMappingCollection interface directly, but initializes an instance of a class that inherits IColumnMappingCollection.
Classes that inherit IColumnMappingCollection must implement the inherited members, and typically define additional members to add provider-specific functionality. For example, the IColumnMappingCollection interface defines one implementation of the RemoveAt method. In turn, the DataTableMappingCollection class inherits this method, and defines two additional overloads of RemoveAt.
Notes to Implementers: When you inherit from the IColumnMappingCollection interface, you should implement the following constructor:
Item |
Description |
PrvColumnMappingCollection ( ) |
Initializes an empty PrvColumnMappingCollection class. |
The following example uses an instance of the derived class, DataTableMapping, to Add DataColumnMapping objects to its ColumnMappings collection and displays a list of those mapped source tables. This example assumes that a DataTableMapping has already been created.
void ShowColumnMappings ( ) {
// ... create myTableMap ...
myTableMap.ColumnMappings.Add ( "Category Name", "DataCategory" );
myTableMap.ColumnMappings.Add ( "Description","DataDescription" );
myTableMap.ColumnMappings.Add ( "Picture","DataPicture" );
string myMessage = "Column Mappings:\n";
for ( int i = 0;i < myTableMap.ColumnMappings.Count; i++ ) {
myMessage + = i.ToString ( ) + " " +
myTableMap.ColumnMappings [ ].ToString ( ) + "<br>";
}
Response.Write ( myMessage );
}
Public Sub ShowColumnMappings ( )
' ... create myTableMap ...
myTableMap.ColumnMappings.Add ( "Category Name", "DataCategory" )
myTableMap.ColumnMappings.Add ( "Description", "DataDescription" )
myTableMap.ColumnMappings.Add ( "Picture", "DataPicture" )
Dim myMessage As String = "Column Mappings:" + ControlChars.Cr
Dim i As Integer
For i = 0 To myTableMap.ColumnMappings.Count - 1
myMessage + = i.ToString ( ) + " " & _
myTableMap.ColumnMappings ( i ).ToString ( ) + ControlChars.Cr
Next i
Response.Write ( myMessage )
End Sub |
|
C# |
VB |