DataTableMappingCollection.Add Metodo
Definizione
Aggiunge un oggetto DataTableMapping alla raccolta.Adds a DataTableMapping object to the collection.
Overload
Add(Object) |
Aggiunge un oggetto Object, che rappresenta un mapping di tabella, all'insieme.Adds an Object that is a table mapping to the collection. |
Add(String, String) |
Aggiunge un oggetto DataTableMapping all'insieme quando viene fornito un nome della tabella di origine e un nome di tabella di DataSet.Adds a DataTableMapping object to the collection when given a source table name and a DataSet table name. |
Add(Object)
Aggiunge un oggetto Object, che rappresenta un mapping di tabella, all'insieme.Adds an Object that is a table mapping to the collection.
public:
virtual int Add(System::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
Parametri
- value
- Object
Oggetto DataTableMapping
da aggiungere alla raccolta.A DataTableMapping
object to add to the collection.
Restituisce
Indice dell'oggetto DataTableMapping
aggiunto all'insieme.The index of the DataTableMapping
object added to the collection.
Implementazioni
Eccezioni
L'oggetto passato non era un oggetto DataTableMapping.The object passed in was not a DataTableMapping object.
Esempi
Nell'esempio seguente viene eseguita la DataTableMapping ricerca di un oggetto all'interno della raccolta.The following example searches for a DataTableMapping within the collection. Se il mapping è presente nella raccolta, viene rimosso.If the mapping exists in the collection, it is removed. Se il mapping non esiste all'interno della raccolta, viene aggiunto alla raccolta e viene visualizzato il relativo indice.If the mapping does not exist within the collection, it is added to the collection and its index is displayed. Nell'esempio si presuppone che DataTableMappingCollection siano state create DataTableMapping una raccolta e un oggetto.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
Add(String, String)
Aggiunge un oggetto DataTableMapping all'insieme quando viene fornito un nome della tabella di origine e un nome di tabella di 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);
member this.Add : string * string -> System.Data.Common.DataTableMapping
Public Function Add (sourceTable As String, dataSetTable As String) As DataTableMapping
Parametri
- sourceTable
- String
Nome, con distinzione tra maiuscole e minuscole, della tabella di origine da cui eseguire il mapping.The case-sensitive name of the source table to map from.
- dataSetTable
- String
Nome, senza distinzione tra maiuscole e minuscole, della tabella di DataSet in base alla quale eseguire il mapping.The name, which is not case-sensitive, of the DataSet table to map to.
Restituisce
Oggetto DataTableMapping aggiunto all'insieme.The DataTableMapping object that was added to the collection.
Esempi
Nell'esempio seguente viene creato DataTableMappingCollectionun oggetto DataTableMapping , vengono aggiunti oggetti alla raccolta e viene visualizzato un elenco delle tabelle di origine mappate.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