Adding rows to the data table after LINQ

Hello so my situation is:

I have a merged data table which I compare with another datatable (A_B_C) by using LINQ activity in order to have only unique rows as outcome, my code is:

Certsdone - my merged DT
unique row (enumarable list) my uniqe rows = A_B_C_completed.AsEnumerable().Where(Function(raportRow) Not certs_datatable.AsEnumerable().Any(Function(x) x(“Kolumna1”).ToString() = raportRow(“Kolumna1”).ToString() And x(“Kolumna2”).ToString() = raportRow(“Kolumna2”).ToString() And x(“Kolumna3”).ToString() = raportRow(“Kolumna3”).ToString()))

and my question is: how do I later update my CertsDone with unique values? so the values that are saved in my variable uniquerows that I would like to append to Certs DT any ideas?

I need good instructions please

@marcin.chowaniec

CertsDone = CertsDone.AsEnumerable().Concat(uniqueRows).CopyToDataTable()

cheers…!

When the Identity of CertsDone is to keep:

  • Merge DataTable Activity uniqueRows.CopyToDataTable merged to CertsDone

OR

  • Essential for each and Add Data Row using the loop datarow ItemArray

If the Identiy is not mandatory to keep, then as mentioned above using the Concat

BTW: above LINQ can be reduced on the redundand parts by:

Assign Activity:
arrColSet = {“Kolumn1”,“Kolumn2”,“Kolumn3”}

Assign Activity:
uniqueRows =

(From d In A_B_C_completed.AsEnumerable()
Let lcs = arrColSet.Select(Function (x) d(x).ToString.Trim)
Let chk = certs_datatable.AsEnumerable().Any(Function (d2) arrColSet.Select(Function (x2) d2(x2).ToString.Trim).SequenceEqual(lcs))
Where Not chk
Select r = d)

You can’t. There is no link between the variable and the datatable. You’d have to write your logic to update both.

starting with:


we marked dtData at the TableName

Merging:
grafik

CopyToDataTable is realizing it for us, but is creating a new DataTable
grafik
we lost the TableName (which we used for markings)

Hello Peter,

Do you have any idea what do I do wrong here?

uniquerows - is my enumarate list

and certs_datatable is a datatable I would like to append unique rows too

image

the field Add list as row is to use instead

Hello Peter,

I’m getting the error:

I feel very very stuck with this.

check the details from uniquerows variable and the for each setting e.g. TypeArgument: DataRow