abe545 / CodeOnlyStoredProcedures

A library for easily calling Stored Procedures in .NET using only code (no xml or gui).
MIT License
4 stars 3 forks source link

Syntax of WithOutputParameter method #92

Open leevva opened 7 years ago

leevva commented 7 years ago

Documented syntax doesn't work:

string output = null;
StoredProcedure.Create("dbo", "MyStoredProc")
               .WithOutputParameter("Name", s => output = s);

This way it works:

string output = null;
StoredProcedure.Create("dbo", "MyStoredProc")
               .WithOutputParameter<StoredProcedure, string>("Name", s => output = s);
abe545 commented 7 years ago

Yes, that does seem to be an issue. I don't think there is a way to force the type system to infer the correct argument type with that syntax. However, you can pass a strongly typed delegate (either an existing method, or a lambda). So, this is a little cleaner, especially if you have a sproc that returns a value:

string output = null;
StoredProcedure.Create("dbo", "MyStoredProc")
               .WithOutputParameter("Name", new Action<string>(s => output = s));