C # DataSet.Relations: How to use DataSet relationships?

I have 3 tables, and I have established relationships for each of them.

let's say: table 1 has: aID, bID, cID, someText and someNumber

Table 2 has: bID, txtValueTable2, someText

table 3 has: cID, txtValueTable3, someText

some code:

ds.Relations.Add("BrandNameStr", ds.Tables[1].Columns["bID"], ds.Tables[0].Columns["bID"]); ds.Relations.Add("IngredientStr", ds.Tables[2].Columns["cID"], ds.Tables[0].Columns["cID"]); 

Now I want to use columns from all three tables to make 1 dataset, but I don’t know how?

The data set must have the following columns: aID, txtValueTable2, txtValueTable3, someText and someNumber

Can someone help me?

+6
source share
2 answers

There is a good example here.

In a few words, you should use the DataTabel.GetChildRows () method.

Here is a working example.

+4
source

Hi, you need to change this:

ds.Relations.Add ("BrandNameStr", ds.Tables [0] .Columns ["bID"], ds.Tables [1] .Columns ["bID"]);

0
source

Source: https://habr.com/ru/post/898659/


All Articles