How to do joining of two table in EF ?


Hi
So many time we will get situation to join two table on basis of some condition. If we have to do inner join in Entity Framework then we can do like this

using (TestEntities TE = new TestEntities())
{
var query = from m in TE.tblEmps
join d in TE.tblDepts on m.Id equals d.Id
select new {m.EmpName,d.DeptName};

GridView1.DataSource = query;
GridView1.DataBind();

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: