Using T4 templates & OrmLiteSPStatement object for OUTPUT parameters

We have a lot of existing databases I am trying to port over to use OrmLite instead of EF6, we also happen to have a lot of stored procedures with OUTPUT parameters.

First off there are some “bugs” in the T4 templates relating to In/InOut/Output ParameterDirection, I have solved those (and will submit my fixes back later), but ran into a issue that the OrmLiteSPStatement.

OrmLiteSPStatement has the IDbCommand it generates as private, and I have no way to access my output parameters once I call ExecuteNonQuery(). Before I start hacking away at this any further I wanted to make sure I wasn’t missing something or what might need to be changed to allow me to use OUTPUT parms with the T4 generated template process.

No not missing anything, I don’t expect there to be much support for different SP styles in the T4 templates, which only get enhanced as others modify it to support their DB objects.

As a code-first ORM I personally avoid using both the T4 templates and SP’s in general, when I’ve needed to call SP’s with output params I’d just call it with SqlProc, e.g:

using (var cmd = db.SqlProc("spName", new { pArg = "C" }))
    var pTotal = cmd.AddParam("pTotal", direction: ParameterDirection.Output);

    var results = cmd.ConvertToList<LetterFrequency>();
    var total = pTotal.Value;

or the Custom SQL API’s:

IDbDataParameter pTotal = null;
var results = db.SqlList<LetterFrequency>("spSearchLetters", cmd => {
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.AddParam("pLetter", "C");
        pTotal = cmd.AddParam("pTotal", direction: ParameterDirection.Output);
var total = pTotal.Value;

But happy to accept any changes you need to support your use-case.