I am using EF6.1 and bit confused with the two formats of writing the join queries.
var query = (from cc in dbContext.Companies.AsNoTracking()
join dc in dbContext.Departments.AsNoTracking()
on cc.CompanyId equals dc.CompanyId
select new {cc,dc}).ToList().Select(k=> New Company()
{
CompanyId = k.cc.CompanyId,
Departments = k.dc.ToList()
});
vs
var query = dbContext.Comapanies.Include(k=>k.Departments).ToList();
My question is which one should be use and what are the pros and cons.
I found mix feedback on using the Include in case of multiple tables.
As per below article https://msdn.microsoft.com/en-in/data/jj574232.aspx
"Note that it is not currently possible to filter which related entities are loaded. Include will always being in all related entities."
this statement is not very clear as well. Please suggest.