Imagine that we have 3 datatables
, each with a different number of rows,
For example:
DATATABLE A
fila 1 - "a1"
fila 2 - "a2"
DATATABLE B
fila 1 - "b1"
fila 2 - "b2"
fila 3 - "b3"
DATATABLE C
fila 1 - "c1"
fila 2 - "c2"
How can I build a method in C # or VB.NET that returns another DataTable
with a field that includes a row of each of the 3 datatables
with all possible combinations?
That is, I want to get the following result:
DATATABLE RESULTANTE
fila 1 "a1b1c1"
fila 2 "a1b1c2"
fila 3 "a1b2c1"
fila 4 "a1b2c2"
fila 5 "a1b3c1"
fila 6 "a1b3c2"
fila 7 "a2b1c1"
fila 8 "a2b1c2"
fila 9 "a2b2c1"
fila 10 "a2b2c2"
fila 11 "a2b3c1"
fila 12 "a2b3c2"
If you notice, the resulting rows are the result of multiplying the row numbers of each datatable (a b c), but what I can not do is to make a method that results in exposed. I imagine that you have to use recursion, but no matter how many laps I give you, I do not get it.
I want the method to be valid for more combinations, that is, that you do not really care about the number of tables involved or the number of rows in each table, the method must be able to obtain all possible combinations.