DataRelationCollection.AddRange(DataRelation[]) Yöntem

Tanım

Belirtilen DataRelation dizinin öğelerini koleksiyonun sonuna kopyalar.

public:
 virtual void AddRange(cli::array <System::Data::DataRelation ^> ^ relations);
public virtual void AddRange (System.Data.DataRelation[]? relations);
public virtual void AddRange (System.Data.DataRelation[] relations);
abstract member AddRange : System.Data.DataRelation[] -> unit
override this.AddRange : System.Data.DataRelation[] -> unit
Public Overridable Sub AddRange (relations As DataRelation())

Parametreler

relations
DataRelation[]

Koleksiyona eklenecek nesne dizisi DataRelation .

Örnekler

public static void AddRelations(DataSet dataSet)
{
    DataRelation customerOrders =
        new DataRelation("CustomerOrders",
        dataSet.Tables["Customers"].Columns["customerId"],
        dataSet.Tables["Orders"].Columns["customerId"]);

    DataRelation orderDetails =
        new DataRelation("OrderDetail",
        dataSet.Tables["Orders"].Columns["orderId"],
        dataSet.Tables["OrderDetails"].Columns["orderId"]);

    dataSet.Relations.AddRange(new DataRelation[]
        {customerOrders, orderDetails});

    // Display names of all relations.
    foreach (DataRelation relation in dataSet.Relations)
        Console.WriteLine(relation.RelationName.ToString());
}
Public Shared Sub AddRelations(dataSet As DataSet)
    Dim customerOrders As New DataRelation("CustomerOrders", _
        dataSet.Tables("Customers").Columns("customerId"), _
        dataSet.Tables("Orders").Columns("customerId"))
    Dim orderDetails As New DataRelation("OrderDetail", _
        dataSet.Tables("Orders").Columns("orderId"), _
        dataSet.Tables("OrderDetails").Columns("orderId"))

    dataSet.Relations.AddRange(New DataRelation() _
        {customerOrders, orderDetails})

    ' Display names of all relations.
    Dim relation As DataRelation
    For Each relation In dataSet.Relations
        Console.WriteLine(relation.RelationName.ToString())
    Next
End Sub

Açıklamalar

çağrıldıysa BeginInit , AddRange çağrılana kadar EndInit koleksiyona hiçbir nesne eklemez. çağrılırken EndInit , koleksiyon için en son çağrıda AddRangebelirtilen öğelerle doldurulur. BirEndInitBeginInit / dizi içinde birden çok kez çağrılırsaAddRange, yalnızca en son çağrısında AddRange belirtilen öğeler eklenir.

Şunlara uygulanır

Ayrıca bkz.