title: Immediate execution with EF
body: <p>I have this code that executes a Stored Procedure mapped via EF EDM.</p>
  
  <pre><code>meTest&lt;MCTEntities, ObjectResult&lt;retrieveMedia_Result&gt;&gt;(u =&gt; u.retrieveMedia(campaign_id: 1), ConnectionResolver.MCT_DB_Connection);
  </code></pre>
  
  <p>The method:</p>
  
  <pre><code>public static TValue meTest&lt;U, TValue&gt;(Func&lt;U, TValue&gt; func, String connection)
              where U : ObjectContext, new()
          {
              using (U entitiesContext = (U)Activator.CreateInstance(typeof(U), new[] { connection }))
              {
                  return func(entitiesContext);
              }
      }
  </code></pre>
  
  <p>The issue is that retrieveMedia returns <code>ObjectResult&lt;retrieveMedia_Result&gt;</code> and this is done with deferred execution that results in error: <code>Calling 'Read' when the data reader is closed is not a valid operation.</code></p>
  
  <p>Now, I know that I can call ToList() or ToArray(), but is there any other way to force immediate execution? </p>
  
  <p><strong>I am not sure that casting <code>ObjectResult&lt;retrieveMedia_Result&gt;</code> to <code>List&lt;retrieveMedia_Result&gt;</code> is the right thing to do.</strong></p>