Inner Join in LINQ to Entities


using (context db = new context)
{
var query = from t1 in db.table1
join t2 in db.table2 on t1.Id equals t2.Id
where t1.CompanyId == companyId
select new { t1.column1, t1.column2, t2.column1 };
}

Joining Multiple Fields


using (context db = new context)
{
var query = from t1 in db.table1
join t2 in db.table2 on new {Id = t1.Id, Name = t1.Name} equals new {Id = t2.Id, Name = t2.Name}
where t1.CompanyId == companyId
select new { t1.column1, t1.column2, t2.column1 };
}

Get Free Email Updates!

Signup now and receive free offers, discounts & coupon codes

I will never give away, trade or sell your email address. You can unsubscribe at any time.

Leave a Reply

Your email address will not be published. Required fields are marked *

CommentLuv badge