使用C#包含在Linq中 [英] Include in Linq using C#

查看:62
本文介绍了使用C#包含在Linq中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个关于如何在linq中使用Include的问题.我的SQL查询如下:

Hello all,

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

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



请任何人告诉我在linq中使用此方法的方法.我将使用Student DataTable和Exam DataTable,然后将结果生成DataTable.



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.

DataTable result=dtStudent linq dtExam;



谢谢,



Thanks All,

推荐答案

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();


这篇关于使用C#包含在Linq中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆