DataTableMappingCollection.Add Method (Object)

Adds an Object that is a table mapping to the collection.

Namespace: System.Data.Common
Assembly: System.Data (in

public int Add (
	Object value
public final int Add (
	Object value
public final function Add (
	value : Object
) : int
Not applicable.



A DataTableMapping object to add to the collection.

Return Value

The index of the DataTableMapping object added to the collection.

Exception typeCondition


The object passed in was not a DataTableMapping object.

The following example searches for a DataTableMapping within the collection. If the mapping exists in the collection, it is removed. If the mapping does not exist within the collection, it is added to the collection and its index is displayed. The example assumes that a DataTableMappingCollection collection and a DataTableMapping object have been created.

public void ChangedMyMind() 
    // ...
    // create mappings and mapping
    // ...
    if (mappings.Contains((Object) mapping))
        mappings.Remove((Object) mapping);
        mappings.Add((Object) mapping);
        Console.WriteLine("Index of new mapping: "
            + mappings.IndexOf((Object) mapping));

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0