I have to compare the records of a DataTable
with the objects of a list, the , let's say it only has a " codedatatable
" column , the article object, has several fields, id , name , description , price and stock . I would like to get the objects with the same common id . The most I have come to is:
var result = allp.Select(x => x.id).Except(dt.AsEnumerable().Select(y => y["codigo"]));
But it is obvious that I am not doing something right because I am not getting the desired result. Can someone help me please?
You must use the Intersect operator that returns a list of the elements that are in common between the two collections, the Except operator that is the one you are putting is a subtraction of sets, that is, it shows the elements that are in the first collection that are not They are in the second, according to the code that you put as an example, it would be like: