Posted By

housecor on 10/28/10


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Break nested query out of main query in LINQ

 / Published in: C#

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

  1. var universe = from oa in context.vOfficeAddresses where oa.StateProvince == "Ontario" select oa;
  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  

You need to login to post a comment.