Click here to Skip to main content
15,912,294 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,


I know how to perform simple innerjoin operation on two databales like below
XML
DataTable result = (from t1 in dt1.AsEnumerable()
                                    join t2 in dt2.AsEnumerable() on t1.Field<int>("id") equals t2.Field<int>("id")
                                   select t1).CopyToDataTable();


but I want to write and or condition in the above query can any body help me how can I reach this.
like below

XML
DataTable result = (from t1 in dt1.AsEnumerable()
                                    join t2 in dt2.AsEnumerable() on t1.Field<int>("id") equals t2.Field<int>("id") && t1.Field<int>("id2") not equals t2.Field<int>("id2")
                                   select t1).CopyToDataTable();
Posted

1 solution

Hi
I hope the below code will give you some hints.


XML
DataTable result = (from t1 in dt1.AsEnumerable()
                          join t2 in dt2.AsEnumerable() on t1.Field<int>("id") equals t2.Field<int>("id")
                          where  t1.Field<int>("id1") != t2.Field<int>("id2")
                          select t1).CopyToDataTable();
 
Share this answer
 
v2
Comments
Dominic Abraham 18-Dec-12 13:15pm    
If the solution is helpful don't forget to mark it as answer. So that it may help others with similar issues.

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