title: How can I convert IQueryable<T> to ObjectQuery<T>?
body: <p>I'm trying to apply the advice in this post: <a href="http://blogs.msdn.com/b/alexj/archive/2009/06/02/tip-22-how-to-make-include-really-include.aspx" rel="nofollow">Tip 22 - How to make Include really Include</a></p>
  
  <p>It suggests a workaround for ensure eager loading works in the Entity Framework (4.2). That workaround involves casting the IQueryable to an ObjectQuery.</p>
  
  <p>However, when I attempt this, as shown in the post, the query returns a null.</p>
  
  <p>My query is (ctx is a DbContext):</p>
  
  <pre><code>IEnumerable&lt;Coupon&gt; coupons =
      from x in ctx.Coupons
      where x.LanguageCode.Equals("EN", StringComparison.InvariantCultureIgnoreCase) &amp;&amp; x.CategoryId == MainCategoryId &amp;&amp; x.Date &gt;= fromDate &amp;&amp; x.Date &lt;= toDate
      select x;
  </code></pre>
  
  <p>That works as expected.</p>
  
  <p>However, when I use,</p>
  
  <pre><code>IEnumerable&lt;Coupon&gt; coupons =
      (from x in ctx.Coupons
       where x.LanguageCode.Equals("EN", StringComparison.InvariantCultureIgnoreCase) &amp;&amp; x.CategoryId == MainCategoryId &amp;&amp; x.Date &gt;= fromDate &amp;&amp; x.Date &lt;= toDate
       select x) as ObjectQuery&lt;Coupon&gt;;
  </code></pre>
  
  <p>it assigns a null to "coupons".</p>
  
  <p>Any idea what I'm doing wrong?</p>