Click here to Skip to main content
15,564,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have datatable , I need to enumerate it and check against the List objects and take the matching rows from the datatable. But for some reason below returning all the datarows even though it's not matching.

What I have tried:

C#
var joinForUpdate = 
    from rowA in ds.Tables[0].AsEnumerable()
    where fin.Select(y => rowA.Field<int>("B") == y.BID&& y.AID== rowA.Field<int>("A")).Any()
    select rowA;
Posted
Updated 6-Mar-16 9:22am
v3
Comments
Kornfeld Eliyahu Peter 6-Mar-16 7:45am    
You sample as is has a syntax problem of unclosed quotes!!!
CHill60 6-Mar-16 8:37am    
Once you've fixed the syntax issue you can use the Improve question link to correct your post and add some sample data and expected results
[no name] 6-Mar-16 9:14am    
Firstly you have syntax problem with closing double quote. Secondly what is fin in Linq?
Maciej Los 6-Mar-16 9:14am    
What is fin?
MYQueries1 6-Mar-16 14:15pm    
updated the question . could some one tell me what wrong i am doing

fin is the List<test> . test{string BID,string AID}

1 solution

You probably want to use Enumerable.Intersect(TSource)[^] method to get common items on both lists.

C#
var commonitems = SomeList.Intersect(TheOtherList);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900