Break nested query out of main query in LINQ


/ Published in: C#
Save to your folder(s)

Note: An order operator in a subquery will be ignored. The main query controls ordering.


Copy this code and paste it in your HTML
  1. var universe = from oa in context.vOfficeAddresses where oa.StateProvince == "Ontario" select oa;
  2.  
  3. var query = from oa in universe
  4. select new {
  5. oa,
  6. contact = (from c in context.Contacts where c.ContactID == oa.ContactID select c)
  7. };
  8. var AddressesWithContacts = query.ToList();

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.