title: How to handle ObjectResult in Entity Framework 4
body: <p>In Entity Framework 4, I'm facing a problem when I use function import to a stored procedure and then using as a scalar value.  It generates the code below:</p>
  
  <pre><code>public virtual ObjectResult&lt;Nullable&lt;int&gt;&gt; GetTopEmployee()
  {
      return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction&lt;Nullable&lt;int&gt;("GetTopEmployee");
  }
  </code></pre>
  
  <p>How do I use the return value of this method?</p>
  
  <p>For example, this code works fine:</p>
  
  <pre><code>NorthwindEntities db = new NorthwindEntities();
  var i = db.GetTopEmployee();
  </code></pre>
  
  <p>But I want to use return values only as int. If I use return value as non while in function import it give -1 as output.</p>
  
  <p>When I try the code below:</p>
  
  <pre><code>NorthwindEntities db2 = new NorthwindEntities();
  int j = db.GetTopEmployee();
  </code></pre>
  
  <p>It throws an error saying:</p>
  
  <blockquote>
    <p>Cannot implicitly convert type 'System.Data.Objects.ObjectResult' to 'int'</p>
  </blockquote>
  
  <p>How do I parse the above?</p>