Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all,

I have a question about how to use Include in linq. My SQL query is like:

SQL
Select * from tbl_Student where Student_ID include(select * from tbl_Exam)


Please anyone show me a way to use this in linq. I'm going to use Student DataTable and Exam DataTable then result to DataTable.

C#
DataTable result=dtStudent linq dtExam;


Thanks All,
Posted
Updated 5-Nov-12 15:50pm
v2

1 solution

C#
var Source=from student in tbl_Student.AsEnumerable()
           where bl_Exam.AsEnumerable().Any(r=>r.Field<int>                           ("Student_Id")==tbl_Student.Field<int>("Student_ID"))
            select student;
DataTable dtResult=Source.CopyToDataTable();
 
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