3

It seems that the only way to call an Sp with Subsonic 3 is as follows:

StoredProcedure sp = new StoredProcedure("NameOfSP");
mySqlCommand.Parameters.Add("@MyVar", SqlDbType.Int).Value = 1;

I remember some time ago that it was possible to call a stored procedure as a function:

SPs.NameOfSP(1);

Is this still possible with SubSonic? If not, what SP wrapper would provide this functionality?

Jason
  • 1,129
  • 1
  • 9
  • 20
  • It should be possible. What version of Subsonic 3 are you using? is it 3.0.0.0 or 3.0.0.3? – Deano Jul 18 '11 at 09:43

1 Answers1

2

There is a T4 template named "StoredProcedures.tt" that generates the methods to match your stored procedures. If that file is missing, you can re-fetch it from here. The way the template is currently set up, the method takes in the parameters and sets them for you, then returns a StoredProcedure object instance, and I think you might have to call .Execute() on it, like:

SPs.NameOfSP(1).Execute();

but you could easily modify that T4 template to call .Execute() within the SP method call.

CodingWithSpike
  • 42,906
  • 18
  • 101
  • 138