Hi,
I am trying to get matched records from two DT’s but unfortunately unable to do so, whereas when checking manually I find few records matching, but when using LINQ to get the same, I failed to do so, help me rectify-
Note - the amount field having negative values in both the DT.
(From a In DT1.AsEnumerable()
Where DT2.AsEnumerable.Any(Function (b) a("Reference").ToString.Trim.Equals(b("reference").ToString.Trim) And a("Amount").ToString.Equals(b("Amount").ToString))
Select a).CopyToDataTable()
(From a In DT1.AsEnumerable()
From b in DT2.AsEnumerable()
Where a(“Reference”).ToString.Trim.Equals(b(“reference”).ToString.Trim) And a(“Amount”).ToString.Equals(b(“Amount”).ToString)
Select a).CopyToDataTable()
(From a In DT1.AsEnumerable()
Where DT2.AsEnumerable.Any(Function (b) a("Reference").ToString.Trim.Equals(b("reference").ToString.Trim) And Convert.ToDouble(a("Amount")).Equals(Convert.ToDouble(b("Amount"))))
Select a).CopyToDataTable()
we prefer to do it on datetime parsexact as we can do the bot more reliable. Unforseen values let fail the parsing and can be detected.
Any constraints why it should be done other than datetime.ParseExact?
doing it with string base can maybe use strategies like