title: Scalar Value from stored procedure via Entity Framework
body: <p>I have found a few articles like this one:
  <a href="http://devtoolshed.com/using-stored-procedures-entity-framework-scalar-return-values" rel="noreferrer">http://devtoolshed.com/using-stored-procedures-entity-framework-scalar-return-values</a></p>
  
  <p>Yet when I take the step to create a function import for a int32 scalar, this is what gets generated:</p>
  
  <pre><code> public ObjectResult&lt;Nullable&lt;global::System.Int32&gt;&gt; MyStoredProcedure(Nullable&lt;global::System.Int32&gt; orderId)
      {
          ObjectParameter orderIdParameter;
          if (orderId.HasValue)
          {
              orderIdParameter = new ObjectParameter("OrderId", orderId);
          }
          else
          {
              orderIdParameter = new ObjectParameter("OrderId", typeof(global::System.Int32));
          }
  
          return base.ExecuteFunction&lt;Nullable&lt;global::System.Int32&gt;&gt;("MyStoredProcedure", orderIdParameter);
      }
  </code></pre>
  
  <p>I am able to call the procedure with this, but am not able to get to the underlying scalar:<br /></p>
  
  <p><code>ObjectResult&lt;int?&gt; result = myEntities.MyProcedure(orderId);</code></p>
  
  <p>In the code examples I have seen, I should get <code>context.MyProcedure().SingleOrDefault()</code>. </p>