I would like to know how can I use LINQ to compare two DataTable values and return boolean if both values are int the data tables?
DT1 has value G25685 in Column(“Shipment”)
DT2 has G25685 in Column(“Shipment”)
return True if so or False if not
Thank you for all the help in advance.
Do you mean you want to check if some same value exists in specific column of both datatable?
If so, the following will work.
dt1.AsEnumerable.Select(Function(r) r("Shipment").ToString).Intersect(dt2.AsEnumerable.Select(Function(r) r("Shipment").ToString)).Any
Sample20220910-1.zip (2.6 KB)
Hi, thank you, that worked, how could I check if a single data table contains a specific value, let’s say I want to check if DT1 has the value G05468, and if so return a boolean?
How about the following?
Yes this works perfectly, so I have one last question, if the function Contains exist, why can I not use it for datatables?
Can you elaborate? Do you mean String.Contains or IEnumerable.Contains?
I mean IEnumerable.Contains
If we need to use
IEnumerable.Contain for the above latter expression, it will be as the following.
Yes, this worked perfectly as well, thank you so much
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.