DataTableMapping 类

定义

包含有关源表与 DataTable 之间映射关系的说明。Contains a description of a mapped relationship between a source table and a DataTable. 填充 DataAdapter 时,由 DataSet 使用该类。This class is used by a DataAdapter when populating a DataSet.

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

示例

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

public void AddDataTableMapping() 
{
    // ...
    // create tableMappings
    // ...
    DataTableMapping mapping =
        new DataTableMapping("Categories","DataCategories");
    tableMappings.Add((Object) mapping);
    Console.WriteLine("Table {0} added to {1} table mapping collection.",
        mapping.ToString(), tableMappings.ToString());
}
Public Sub AddDataTableMapping()
    ' ...
    ' create tableMappings
    ' ...
    Dim mapping As New DataTableMapping( _
       "Categories", "DataCategories")
    tableMappings.Add(CType(mapping, Object))
    Console.WriteLine( _
       "Table {0} added to {1} table mapping collection.", _
       mapping.ToString(), tableMappings.ToString())
End Sub

注解

DataTableMapping 提供对数据源的查询返回的数据与 DataTable之间的主映射。A DataTableMapping provides a master mapping between the data returned from a query against a data source, and a DataTable. DataTableMapping 名称可以传递给DataAdapterFill 方法,而不是 DataTable 名称。The DataTableMapping name can be passed in place of the DataTable name to the Fill method of the DataAdapter. 有关详细信息,请参阅DataAdapter DataTable And DataColumn 映射For more information, see DataAdapter DataTable and DataColumn Mappings.

构造函数

DataTableMapping()

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

DataTableMapping(String, String)

给定源表名称和 DataTableMapping 名称时,使用源初始化 DataTable 类的新实例。Initializes a new instance of the DataTableMapping class with a source when given a source table name and a DataTable name.

DataTableMapping(String, String, DataColumnMapping[])

给定源表名称、DataTableMapping 名称和 DataTable 对象数组时,初始化 DataColumnMapping 类的新实例。Initializes a new instance of the DataTableMapping class when given a source table name, a DataTable name, and an array of DataColumnMapping objects.

属性

ColumnMappings

获取 DataColumnMappingCollectionDataTableGets the DataColumnMappingCollection for the DataTable.

DataSetTable

获取或设置 DataSet 中的表名。Gets or sets the table name from a DataSet.

SourceTable

获取或设置数据源中区分大小写的源表名称。Gets or sets the case-sensitive source table name from a data source.

方法

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)
GetColumnMappingBySchemaAction(String, MissingMappingAction)

使用指定的 DataColumn 值和 DataTable 的名称从指定的 MissingMappingAction 中获取 DataColumnGets a DataColumn from the specified DataTable using the specified MissingMappingAction value and the name of the DataColumn.

GetDataColumn(String, Type, DataTable, MissingMappingAction, MissingSchemaAction)

为给定的列名返回 DataColumn 对象。Returns a DataColumn object for a given column name.

GetDataTableBySchemaAction(DataSet, MissingSchemaAction)

使用指定的 DataTable 值获取指定 DataSet 的当前 MissingSchemaActionGets the current DataTable for the specified DataSet using the specified MissingSchemaAction value.

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()

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

显式接口实现

ICloneable.Clone()

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

ITableMapping.ColumnMappings

获取 DataColumnMappingCollection 的派生 DataTableGets the derived DataColumnMappingCollection for the DataTable.

适用于

另请参阅