title: LINQ to Dynamics CRM query optimisation
body: <p>I'm working with a website that links into a Dynamics CRM Online. I'm new to both of these but find the best way to learn is to put yourself under pressure.</p>
  
  <p>Anyway, I have the following LINQ query that I've built using LinqPad:</p>
  
  <pre class="lang-cs prettyprint-override"><code>from m in py3_membershipSet
  join c in ContactSet on m.py3_Member.Id equals c.ContactId 
  where m.statuscode.Value == 1
  orderby m.py3_name
  select m
  </code></pre>
  
  <p>However, this gives an out of memory exception. It runs ok if I use Take(100) but I expect there to be about 1200 results to retrieve in total. Whether the memory issue is a LinqPad related problem I don't know but either way, I am assuming the above query isn't the most efficient way to pull these results.</p>
  
  <p>I could really do with some help on making this more efficient, if it is as much of a memory hog as it appears via LinqPad.</p>