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

Dynamic stored procedures don't close their connection when the result is not cast #69

Open abe545 opened 8 years ago

abe545 commented 8 years ago

49 fixed the issue when the result is cast to something. However, if the results are never cast to a different object, the connection is never closed. This is a big issue for code like the following:

public async Task Call()
{
    try
    {
        await connection.ExecuteAsync().usp_Sproc();
    }
    catch (Exception ex)
    {
        Log(ex);
        throw;
    }
}
abe545 commented 8 years ago

This is unfortunately not fixable with this style of calling. How would we know when the result is no longer needed? However, developers can mitigate the issue if they use the new ExecuteNonQueryAsync (merged in #86 ):

public async Task Call()
{
    try
    {
        await connection.ExecuteNonQueryAsync().usp_Sproc();
    }
    catch (Exception ex)
    {
        Log(ex);
        throw;
    }
}