DataTableMappingCollection.Add Método
Definición
Agrega un objeto DataTableMapping a la colección.Adds a DataTableMapping object to the collection.
Sobrecargas
Add(Object) |
Agrega un Object, que es una asignación de tabla, a la colección.Adds an Object that is a table mapping to the collection. |
Add(String, String) |
Agrega un objeto DataTableMapping a la colección cuando se especifica un nombre de tabla de origen y un nombre de tabla de DataSet.Adds a DataTableMapping object to the collection when given a source table name and a DataSet table name. |
Add(Object)
public:
virtual int Add(System::Object ^ value);
public int Add (object? value);
public int Add (object value);
abstract member Add : obj -> int
override this.Add : obj -> int
Public Function Add (value As Object) As Integer
Parámetros
- value
- Object
Objeto DataTableMapping
que se va a agregar a la colección.A DataTableMapping
object to add to the collection.
Devoluciones
Índice del objeto DataTableMapping
agregado a la colección.The index of the DataTableMapping
object added to the collection.
Implementaciones
Excepciones
El objeto que se ha pasado no era un objeto DataTableMapping.The object passed in was not a DataTableMapping object.
Ejemplos
En el siguiente ejemplo se busca un DataTableMapping dentro de la colección.The following example searches for a DataTableMapping within the collection. Si la asignación existe en la colección, se quita.If the mapping exists in the collection, it is removed. Si la asignación no existe en la colección, se agrega a la colección y se muestra su índice.If the mapping does not exist within the collection, it is added to the collection and its index is displayed. En el ejemplo se da por supuesto que DataTableMappingCollection se ha creado una colección y un DataTableMapping objeto.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);
}
else
{
mappings.Add((Object) mapping);
Console.WriteLine("Index of new mapping: "
+ mappings.IndexOf((Object) mapping));
}
}
Public Sub ChangedMyMind()
' ...
' create mappings and mapping
' ...
If mappings.Contains(CType(mapping, Object)) Then
mappings.Remove(CType(mapping, Object))
Else
mappings.Add(CType(mapping, Object))
Console.WriteLine("Index of new mapping: " _
+ mappings.IndexOf(CType(mapping, Object)).ToString())
End If
End Sub
Se aplica a
Add(String, String)
Agrega un objeto DataTableMapping a la colección cuando se especifica un nombre de tabla de origen y un nombre de tabla de DataSet.Adds a DataTableMapping object to the collection when given a source table name and a DataSet table name.
public:
System::Data::Common::DataTableMapping ^ Add(System::String ^ sourceTable, System::String ^ dataSetTable);
public System.Data.Common.DataTableMapping Add (string? sourceTable, string? dataSetTable);
public System.Data.Common.DataTableMapping Add (string sourceTable, string dataSetTable);
member this.Add : string * string -> System.Data.Common.DataTableMapping
Public Function Add (sourceTable As String, dataSetTable As String) As DataTableMapping
Parámetros
- sourceTable
- String
Nombre de la tabla de origen desde la que se va a asignar (con distinción entre mayúsculas y minúsculas).The case-sensitive name of the source table to map from.
- dataSetTable
- String
Nombre de la tabla de DataSet que se va a asignar (sin distinción entre mayúsculas y minúsculas).The name, which is not case-sensitive, of the DataSet table to map to.
Devoluciones
El objeto DataTableMapping que se ha agregado a la colección.The DataTableMapping object that was added to the collection.
Ejemplos
En el ejemplo siguiente se crea un DataTableMappingCollection objeto, se agregan DataTableMapping objetos a la colección y se muestra una lista de las tablas de origen asignadas.The following example creates a DataTableMappingCollection, adds DataTableMapping objects to the collection, and displays a list of the mapped source tables.
public void CreateTableMappings()
{
DataTableMappingCollection mappings =
new DataTableMappingCollection();
mappings.Add("Categories","DataCategories");
mappings.Add("Orders","DataOrders");
mappings.Add("Products","DataProducts");
string message = "TableMappings:\n";
for(int i=0;i < mappings.Count;i++)
{
message += i.ToString() + " "
+ mappings[i].ToString() + "\n";
}
Console.WriteLine(message);
}
Public Sub CreateTableMappings()
Dim mappings As New DataTableMappingCollection()
mappings.Add("Categories", "DataCategories")
mappings.Add("Orders", "DataOrders")
mappings.Add("Products", "DataProducts")
Dim message As String = "TableMappings:" & ControlChars.Cr
Dim i As Integer
For i = 0 To mappings.Count - 1
message &= i.ToString() & " " + mappings(i).ToString() _
& ControlChars.Cr
Next i
Console.WriteLine(message)
End Sub