如何使用linq查询连接两个表

如何使用linq查询连接两个表

问题描述:

先生



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

我在两者中都包含一个公共列列 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.