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

WithOutputParameter doesn't return value #96

Closed leevva closed 7 years ago

leevva commented 7 years ago

It seems that it is not possible to get output value. My setup:

            int totalCount = 0;
            var response = StoredProcedure.Create("contents", "content_search")
                .WithParameter("page_number", settings.Paging.PageNumber)
                .WithParameter("page_size", settings.Paging.PageSize)
                .WithOutputParameter("total_count", new Action<int>(s => totalCount = s))
                .WithResults<ContentSearchResultSet>()
                .Execute(DbContext.Database.Connection);
CREATE PROCEDURE [contents].[content_search]
    @page_number        INT = 1,
    @page_size          INT = 25,
    @total_count        INT OUTPUT
AS
...

Looks like setter is not invoked

abe545 commented 7 years ago

That is strange, I definitely use this behavior, and it has worked in the past. For troubleshooting purposes, does it work if you move the .WithResults directly after the .Create? That is how I always create my sprocs, so maybe this is a bug that only crops up due to the order in which the methods are called.

leevva commented 7 years ago

No, it doesn't work.

abe545 commented 7 years ago

This is so strange. I've been able to replicate the behavior. I guess I never used an out parameter with a result set before...

leevva commented 7 years ago

In 2.4.0-pre02 it works, thanks