DataColumnMapping 类

定义

包含从 DataAdapter 继承的对象的一般列映射。Contains a generic column mapping for an object that inherits from DataAdapter. 无法继承此类。This class cannot be inherited.

public ref class DataColumnMapping sealed : MarshalByRefObject, ICloneable, System::Data::IColumnMapping
[System.ComponentModel.TypeConverter(typeof(System.Data.Common.DataColumnMapping/DataColumnMappingConverter))]
[System.ComponentModel.TypeConverter(typeof(System.Data.Common.DataColumnMappingConverter))]
public sealed class DataColumnMapping : MarshalByRefObject, ICloneable, System.Data.IColumnMapping
type DataColumnMapping = class
    inherit MarshalByRefObject
    interface IColumnMapping
    interface ICloneable
Public NotInheritable Class DataColumnMapping
Inherits MarshalByRefObject
Implements ICloneable, IColumnMapping
继承
DataColumnMapping
属性
实现

示例

下面的示例创建一个 DataColumnMapping 对象并将其添加到 DataColumnMappingCollection中。The following example creates a DataColumnMapping object and adds it to a DataColumnMappingCollection. 然后,它会通知用户已将映射添加到集合,并显示映射的父项。It then tells the user that the mapping was added to the collection and shows the Parent for the mapping.


public void AddDataColumnMapping() {
   // ...
   // create columnMappings
   // ...
   DataColumnMapping mapping =
      new DataColumnMapping("Description","DataDescription");
   columnMappings.Add((Object) mapping);
   Console.WriteLine("Column {0} added to column mapping collection {1}.", 
       mapping.ToString(), columnMappings.ToString());
}
Public Sub AddDataColumnMapping()
    ' ...
    ' create columnMappings
    ' ...
    Dim mapping As New DataColumnMapping( _
       "Description", "DataDescription")
    columnMappings.Add(CType(mapping, Object))
    Console.WriteLine("Column {0} added to column mapping collection {1}.", _
       mapping.ToString(), columnMappings.ToString())
End Sub

注解

使用 DataColumnMapping,可以在与数据源不同的 DataTable 中使用列名。A DataColumnMapping enables you to use column names in a DataTable that are different from those in the data source. DataSet 或数据源中的表更新时,DataAdapter 将使用映射来匹配列。The DataAdapter uses the mapping to match the columns when the tables in the DataSet or data source are updated. 有关详细信息,请参阅DataAdapter DataTable And DataColumn 映射For more information, see DataAdapter DataTable and DataColumn Mappings.

构造函数

DataColumnMapping()

初始化 DataColumnMapping 类的新实例。Initializes a new instance of the DataColumnMapping class.

DataColumnMapping(String, String)

使用指定的源列名称和要映射到的 DataColumnMapping 列名初始化 DataSet 类的新实例。Initializes a new instance of the DataColumnMapping class with the specified source column name and DataSet column name to map to.

属性

DataSetColumn

获取或设置 DataSet 中要映射到的列的名称。Gets or sets the name of the column within the DataSet to map to.

SourceColumn

获取或设置数据源中从其映射的列的名称。Gets or sets the name of the column within the data source to map from. 该名称区分大小写。The name is case-sensitive.

方法

CreateObjRef(Type)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(继承自 MarshalByRefObject)
Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetDataColumnBySchemaAction(DataTable, Type, MissingSchemaAction)

使用 DataColumnDataTable 属性从给定的 MissingSchemaAction 获取 DataSetColumnGets a DataColumn from the given DataTable using the MissingSchemaAction and the DataSetColumn property.

GetDataColumnBySchemaAction(String, String, DataTable, Type, MissingSchemaAction)

GetDataColumnBySchemaAction(DataTable, Type, MissingSchemaAction) 的静态版本,可以在不实例化 DataColumnMapping 对象的情况下调用。A static version of GetDataColumnBySchemaAction(DataTable, Type, MissingSchemaAction) that can be called without instantiating a DataColumnMapping object.

GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetLifetimeService()

检索控制此实例的生存期策略的当前生存期服务对象。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(继承自 MarshalByRefObject)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
InitializeLifetimeService()

获取生存期服务对象来控制此实例的生存期策略。Obtains a lifetime service object to control the lifetime policy for this instance.

(继承自 MarshalByRefObject)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
MemberwiseClone(Boolean)

创建当前 MarshalByRefObject 对象的浅表副本。Creates a shallow copy of the current MarshalByRefObject object.

(继承自 MarshalByRefObject)
ToString()

将当前的 SourceColumn 名称转换为字符串。Converts the current SourceColumn name to a string.

显式接口实现

ICloneable.Clone()

创建作为当前实例副本的新对象。Creates a new object that is a copy of the current instance.

适用于

另请参阅