linq - Get data from multiple table using Entity Framework 5 -


in database, have 4 tables relationship this:

inspection --> correspondence --> correspondenceto, user

now, when inspectionid equals something, want subject, correspondencetype, sentdate correspondence, displayname user, firstname, lastname correspondenceto. write code this:

var result = in context.inspections         join correspondence in context.correspondences              on i.id equals correspondence.inspectionid         join correspondenceto in context.correspondencetoes              on correspondence.id equals correspondenceto.correspondenceid         join user in context.users              on correspondence.senderuserid equals user.id          i.id == inspectionid         select new         {             subject = correspondence.subject,             correspondencetype = correspondence.correspondencetype,             sentdate = correspondence.sentdate,             sender = user.displayname,             receiver = new             {                correspondenceto.firstname,                correspondenceto.lastname             }         }; return json(result); 

what's wrong code? how see result in visual studio 2012? besides, want left join tables above. should do? if want use include instead of join, how that?


Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -