title: Execute stored procedure with PetaPoco
body: <p>I have a stored procedure which returns back a table value.</p>
  
  <p>Here is my stored procedure:</p>
  
  <pre><code>PROCEDURE [GetPermitPendingApproval] 
      @permitYear int = NULL, 
  AS
  BEGIN
          SELECT [p].[ID]
            ,[p].[PermitNumber] 
            ,[p].[PermitTypeID]
            ,[p].[ApplicationDate]
            ,[u].[FirstName]
            ,[u].[MI]
            ,[u].[LastName]
            ,[u].[Suffix]
            ,[u].[ProfessionalTitle]
            ,[u].[WorksFor] 
        FROM [SciCollUser] u 
              INNER JOIN UserPermit up ON up.[UserID] = u.[ID] 
              INNER JOIN Permit p ON p.[ID] = [up].[PermitID] 
       WHERE (@permitYear IS NULL OR p.PermitYear = @permitYear) 
      ORDER BY [p].[ApplicationDate] ASC;
  END
  </code></pre>
  
  <p>I am not sure whether we have such a way to use PetaPoco to execute a stored procedure and get a returned data as a table? Please help!</p>
  
  <p>As normally I can execute a stored procedure with the follow script but it is not the way I want.</p>
  
  <pre><code>db.Execute("EXEC GetPermitPendingApproval @permitYear=2013");
  </code></pre>