DataRelationCollection.AddRange(DataRelation[]) Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Copies the elements of the specified DataRelation array to the end of the collection.
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())
- relations
- DataRelation[]
The array of DataRelation objects to add to the collection.
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
If BeginInit has been called, AddRange
does not add any objects to the collection until EndInit is called. At the time that EndInit
is called, the collection will be populated with the items specified in the most recent call to AddRange
. If AddRange
is called multiple times within a BeginInit
/ EndInit
sequence, only those items specified in the most recent call to AddRange
are added.
Product | Versions |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: