I need a solution which compares, DT1(“country”).tostring.split(“_”)(2) ( i.e Australia) with DT2(“country”). if both are equal then I need to replace DT1(country) with DT2(actualcountry)
To be honest there would not be any performance difference …but here it is
First clone dt1 dtoutput = dt1.Clone()
dtOutput = (From d In Dt1.AsEnumerable() Let val = if(dt2.AsEnumerable.Any(function(x) x("Country").ToString.Equals(d("Country").ToString.Split({"_"},StringSplitOptions.None)(2)),dt2.AsEnumerable.Where(function(x) x("Country").ToString.Equals(d("Country").ToString.Split({"_"},StringSplitOptions.None)(2)))(0)("ActualCountry"),d("Country").ToString) Let ra = New Object(){d("AcNo"),d("Date"),val,d("amount")} Select r = DTOutput.Rows.Add(ra)).CopyToDataTable()
(From d In Dt1.AsEnumerable()
Let val = If(dt2.AsEnumerable.
Any(Function(x) x("Country").ToString.Equals(d("Country").ToString.Split({"_"},StringSplitOptions.None)(2))),
dt2.AsEnumerable.Where(Function(x) x("Country").ToString.Equals(d("Country").ToString.Split({"_"},StringSplitOptions.None)(2)))(0)("ActualCountry"),
d("Country").ToString)
Let ra = New Object(){d("AcNo"),d("Date"),val,d("amount")}
Select r = dtoutput.Rows.Add(ra)).CopyToDataTable()
First I gave you a simple solution only…but you wanted it like this…so please tell the actual requirement and explain what you need so that we can help you better