title: How to get dynamic SQL result from SP in entity framework?
body: <p>Suppose I have following SP to run a dynamic sql
  ALTER  PROCEDURE [dbo].[MySP] 
  AS
      BEGIN</p>
  
  <pre><code>declare @sql varchar(4000)
  select @sql = 'select cnt = count(*) from Mytable ..... ';
  exec (@sql)
  
  END
  </code></pre>
  
  <p>then in edmx, I add the sp and import function for this sp. the return type is scalars int32.</p>
  
  <p>then I want to use this function in code like:</p>
  
  <pre><code>int? result = context.MySP();
  </code></pre>
  
  <p>I got error said "cannot implicitly convert type System.Data.Objects.ObjectResults to int?"</p>
  
  <p>If use </p>
  
  <pre><code>   var result = context.MySP();
  </code></pre>
  
  <p>then Single() cann't be applied to context.MySP().</p>
  
  <p>How to get the result for this case?</p>