Hello,
I have one excel file in which there are 40 Columns and based on certain conditions I need to update the values in the C, D columns
Can anyone help me to write Linq for each to update the values in multiple columns?
Hello,
I have one excel file in which there are 40 Columns and based on certain conditions I need to update the values in the C, D columns
Can anyone help me to write Linq for each to update the values in multiple columns?
What is the condition? Need more information to construct the LINQ.
I have another excel where the ID is stored.
I need to search the ID in the my input excel if the ID is found I need to update the column C, D as βFoundβ
refer below code
Dim dt_Code As DataTable = New DataTable(βtable1β)
dt_Code.Columns.Add(βidβ, GetType(String))
dt_Code.Columns.Add(βvalueβ, GetType(String))
dt_Code.Rows.Add({β1β,βaβ})
dt_Code.Rows.Add({β2β,βbβ})
dt_Code.Rows.Add({β3β,βcβ})
dt_Code.Rows.Add({β4β,βdβ})
dt_Code.Rows.Add({β5β,βeβ})
'ID String Array
Dim arr_ids() As String = dt_Code.AsEnumerable().Select(Function(r) r(βidβ).ToString).ToArray
Dim dt As DataTable = New DataTable(βtable2β)
dt.Columns.Add(βidβ, GetType(String))
dt.Columns.Add(βcheckβ, GetType(String))
dt.Rows.Add({β1β,ββ})
dt.Rows.Add({β3β,ββ})
dt.Rows.Add({β5β,ββ})
dt.Rows.Add({β7β,ββ})
dt.Rows.Add({β9β,ββ})
For Each r In dt.Rows
r(βcheckβ) = If(arr_ids.Contains(r(βidβ)),βFoundβ,βNot Foundβ)
Next r
Hello @park363
Thank you for your reply,
I just want to achieve this using Linq.
With just one assign statement.
Thank you,
Prashant
Try this
(From r In inputDT
Let s = If(otherDT.AsEnumerable.Select(Function (x) x(0).ToString).ToArray.Contains(r(0).ToString), "Found", "Not Found" )
Let a = r.ItemArray.Take(2).ToArray
Let b = a.Append(s).toArray
Let c = b.append(s).ToArray
Let d = c.Concat(r.ItemArray.Skip(4).ToArray).ToArray
Select outDT.Rows.Add(d)).CopyToDataTable
I have one excel file in which there are 10 Columns and I need to check with a condition if it was true I need to update the values in the D column using linq query?
Can anyone help�
Hello @Sai_Pappu ,
As a best Forum practice, when you have a question, create a new post on the forum.
Best,
Charbel