subsonic / SubSonic-3.0

SubSonic 3.0 for the .NET 3.5 Framework
http://subsonic.github.io/
557 stars 209 forks source link

Execute* methods in SubSonic.Core\Schema\StoredProcedure.cs do not process OutputParameters or ReturnValues #279

Open tgeorge73 opened 12 years ago

tgeorge73 commented 12 years ago

With the exception of the .Execute() method, the other Execute* methods of the StoredProcedure class do not make a call to the Command's GetOutputParameters method. This results in null output parameters and return values when using these methods. I first came across this issue when we used a non-zero return value from the proc to indicate why the resultset was empty (using the ExecuteTypedList method). (Using SQL 2008 as back end database).

Caveat I do not fully understand the ramifications (if any) outside my testing to the changes I am mentioning which, at least in the case of SQL Server 2008, correct this deficiency.

1) I modified the IDataProvider interface to provide an overload to ExecuteReader when returns out as a second argument the DbCommand object that was used to invoke the call. (By overloading the method, I prevented breaking code I do not understand at this time, but admit I do not fully understand the ramifications to modifying this interface if others have already implemented it outside of the SubSonic.Code project.) 2) Within DbDataProvider I:

While I would love to formally submit these changes as a Pull Request, I am unsure of the ramifications of my changes to the other database types and without being able to run the unit tests included in the git source solution, I figured I'd rather be safe than sorry.

I did create a set of 8 standalone stored procedures SQL Server stored procedures as well as xUnit tests for all the conditions where I discovered the call to GetOutputParameters was missing and the tests now show the code changes as functional. (visual studio 2010 project)

Finally, note that in order for OutputParameter to be functional, the StoredProcedure.cs that the templates generate must be hand manipulated as they are not correctly identified as pointed out in Issue # 118. Additionally, the T4 template must be updated so that it inserts the following before the return sp; line: sp.Command.AddReturnParameter();

-Tim