title: C#: Is it possible to declare a local variable in an anonymous method?
body: <p>Is is possible to have a local variable in an anonymous c# methods, i.e. in the following code I would like to perform the count only once.</p>
  
  <pre><code>IQueryable&lt;Enquiry&gt; linq = db.Enquiries;
  
  if(...) linq = linq.Where(...);
  
  if(...) linq = linq.Where(e =&gt; 
      (x &lt;= (from p in db.Orders where p.EnquiryId == e.Id select p).Count() &amp;&amp; 
          (from p in db.Orders where p.EnquiryId == e.Id select p).Count() &lt;= y));
  
  if(...) linq = linq.Where(...);
  
  var result = (from e in linq select e);
  </code></pre>
  
  <p>Is there a "let" for anonymous functions?</p>
  
  <p>Update:
  Note that I'm adding several Where clauses after this statement so I can't close with a select.</p>
  
  <p>/Niels</p>