Using Subsonic 3.0.0.3 is it feasible to pass a null value to a stored procedures parameter? If so, what is the appropriate way?
Details
Say I have an sp where one of the parameters has a default value like:
CREATE Procedure Test_SPWithNullParams( @p1 int=null, @p2 varchar(50) )
AS
SELECT 1 as Stuff
Then in my code I want to do something like:
var db = new Sandbox.DB();
StoredProcedure sproc = db.Test_SPWithNullParams( null , "test");
//alternately --> db.Test_SPWithNullParams("test");
The way the corresponding function generated in StoredProcedures.cs, however, the parameter for @p1 is not nullable. So what are my alternatives? I came across this article (http://brianmrush.wordpress.com/2010/01/19/subsonic-t4-templates-stored-procedures-nullable-parameters) but it seems like a cumbersome work around that effectively branches the code base.
Alternatively I've thought about manually overriding the command object. Something like:
int dummyInt = -1;
StoredProcedure sproc = db.Test_SPWithNullParams( dummyInt , "test");
sproc.Command.Parameters[0].ParameterValue = DBNull.Value;
Thoughts?