code_junkie

How to query (LINQ) multiple table association link?

Nov 13th, 2011
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. // Where CaseId and TypeId are your members of CaseClient
  2. var x = caseClients.Join( cases, cc => cc.CaseId, c => c.Id)
  3. .Join( types, cc => cc.TypeId, t => t.Id)
  4. .Select();
  5.  
  6. IEnumerable<Case> getCaseByClient(int client_id)
  7. {
  8. var ret = from c in Cases
  9. join cc in CasesClients
  10. on c.Id equals cc.ClientId
  11. join cl in Clients
  12. on cc.ClientId equals client_id
  13. select c;
  14. return ret;
  15. }
Add Comment
Please, Sign In to add comment