System.Data Namespace
Associates a data source column with a DataSet column, and is implemented by the DataColumnMapping class, which is used in common by .NET data providers.
Class |
Description |
DataColumnMapping |
Contains a generic column mapping for an object that inherits from DataAdapter. This class cannot be inherited. |
The IColumnMapping interface allows an inheriting class to implement a ColumnMapping class, which associates a data source column with a DataSet column. For more information, see Setting Up DataTable and DataColumn Mappings.
An application does not create an instance of the IColumnMapping interface directly, but initializes an instance of a class that inherits IColumnMapping.
Classes that inherit IColumnMapping must implement the inherited members, and typically define additional members to add provider-specific functionality. For example, the IColumnMapping interface defines the DataSetColumn property. In turn, the DataColumnMapping class inherits this property, and also defines the GetDataColumnBySchemaAction method.
Notes to Implementers: When you inherit from the IColumnMapping interface, you should implement the following constructors:
Item |
Description |
DataColumnMapping ( ) |
Initializes a new instance of the ColumnMapping class. |
ColumnMapping ( string sourceColumn, string dataSetColumn ) |
Initializes a new instance of the ColumnMapping class with a source when given a source column name and a DataSet column name to map. |
The following example initializes an instance of the derived class, DataColumnMapping, and adds it to a DataColumnMappingCollection . It then tells the user that the mapping was added to the collection and shows the mapping' s Parent.
void AddDataColumnMapping ( ) {
// ... create myColumnMappings ...
DataColumnMapping myNewMapping = new DataColumnMapping
( "Description","DataDescription" );
myColumnMappings.Add ( ( Object ) myNewMapping );
Response.Write ( "column " + myNewMapping.ToString ( ) +
" added to " +
"column mapping collection " + myColumnMappings.ToString ( ) );
}
Public Sub AddDataColumnMapping ( )
' ... create myColumnMappings ...
Dim myNewMapping As New DataColumnMapping _
( "Description", "DataDescription" )
myColumnMappings.Add ( CType ( myNewMapping, Object ) )
Response.Write ( "column " & myNewMapping.ToString ( ) & _
" added to " & _
"column mapping collection " & myColumnMappings.ToString ( ) )
End Sub |
|
C# |
VB |