如何使用linq查询连接两个表 [英] how to join two tables using linq query

查看:282
本文介绍了如何使用linq查询连接两个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生



我在sqlserver中创建两个表这些是Employee,Dept

我在两者中都包含一个公共列列< b> deptno



当我点击按钮时,我的应用程序中有一个按钮控件这两个表连接并使用LINQ查询显示在gridview中





请回复我。

sir

I create two tables in sqlserver Those are Employee,Dept
I contain a common column column in both that is deptno

I have a button control in my application when iam click button these two tables are joined and displayed in gridview using LINQ query


Pls reply me.

推荐答案

这是它的样子。 br />
Here is what it looks like.
var query = from e in Employee
join d in Dept on  e.deptno equals d.deptno
select new {e.deptno, d.deptno};





[已编辑]

请参阅以下链接,如何将表格映射到LINQ to Entity框架。

LINQ教程:将表映射到对象 [ ^ ]

ADO实体框架。 [ ^ ]


嗨Kranthi,



在Google中试用与'加入LINQ'。请参阅 Google搜索结果 [ ^ ]



这里有一些有用的链接

链接1 [ ^ ]

链接2 [ ^ ]

LINQ查询表达式[ ^ ]
Hi Krant

Try in Google with 'Joins in LINQ'. See Google Results[^]

Some useful links here
Link 1[^]
Link 2[^]
LINQ Query Expressions [^]


Google [ ^ ]是你的朋友和 1 link [ ^ ]其中。
Google[^] is your friend and 1 link[^] among them.


这篇关于如何使用linq查询连接两个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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