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.
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.
How can I know the length of the output parameter in advance?
Here's my DAL class, using attributes to denote the output parameter:
[StoredProcedure("usp_PostARTransaction", OperationType.Insert)]
public class ARTranPost : DataObjectBase<ARTranPost>
{
[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; }
}
Do I need to use SMO or some other library to get the length from the database?