title: How to determine size property for stored procedure output parameters in C# data access layer
body: <p>I've made a data access layer modeled shamelessly off of Castle Project's ActiveRecord implementation. In order for it to gain acceptance, it must support the extensive library of stored procedures in use at my organization, which have been written to use every input/output structure imaginable, including return values and output parameters of every conceivable datatype.</p>
  
  <p>My problem is in developing the code that adds the output parameter to the parameters collection of the Command object used to execute the stored procedure. Right now I'm just using a large default value, hoping it's enough to catch all the cases, but this feels shoddy.</p>
  
  <p>How can I know the length of the output parameter in advance?</p>
  
  <p>Here's my DAL class, using attributes to denote the output parameter:</p>
  
  <pre><code> [StoredProcedure("usp_PostARTransaction", OperationType.Insert)]
      public class ARTranPost : DataObjectBase&lt;ARTranPost&gt;
      {
          [StoredProcedureParameter("sARTranID",OperationType.Insert,ParameterDirection.Output)]
          public string ARTranID {get;set;}
          [StoredProcedureParameter("sDueDate", OperationType.Insert, ParameterDirection.Input)]
          public string DueDate { get; set; }
          [StoredProcedureParameter("sPostDate", OperationType.Insert, ParameterDirection.Input)]
          public string PostDate { get; set; }
  
      }
  </code></pre>
  
  <p>Do I need to use SMO or some other library to get the length from the database?</p>