Closed kinetiq closed 6 years ago
Hmmm that's a good question. I'll see if I can figure out a way for this to be returned.
Get Outlook for Androidhttps://aka.ms/ghei36
From: Brian MacKay notifications@github.com Sent: Friday, August 10, 2018 8:17:36 AM To: snickler/EFCore-FluentStoredProcedure Cc: Subscribed Subject: [snickler/EFCore-FluentStoredProcedure] Rows Affected (#22)
First off, love this project, thanks for putting it out there.
Here's my question: is there a way to get access to rows affected?
I'm using this in a situation where the sproc is just doing some inserts, but no rows are returned. In this case, SQL Server returns the number of rows affected, but so far I don't see a way to get access to that. It seems like it would be a property on handler:
var result = 0;
db.LoadStoredProc("dbo.sproc_ImportUsers") .WithSqlParam("...", "...") ... .ExecuteStoredProc(handler => { result = handler.RowsAffected });
... Or, perhaps even better, just have ExecuteStoredProc return an int and have an overload that doesn't require the handler parameter:
return db.LoadStoredProc("...").ExecuteStoredProc();
Thanks!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fsnickler%2FEFCore-FluentStoredProcedure%2Fissues%2F22&data=02%7C01%7C%7C76622a2f850b4951bec608d5febb42d3%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636695002579840960&sdata=N9p6VavgM%2FiLJ84XMfx4L0jbMVhvwDEZeoQ5iDJjE7M%3D&reserved=0, or mute the threadhttps://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAD1IpYc4QnHOBfolqoNo64jZdBnzLaSSks5uPXnggaJpZM4V4GdY&data=02%7C01%7C%7C76622a2f850b4951bec608d5febb42d3%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636695002579840960&sdata=qeOq5QmwMmiBH%2FhaT1SDZBKmDPnJgTnBI6KwiC1RGT8%3D&reserved=0.
I've proposed an update #23 which adds two new methods for non-query results i.e. just use SQL output parameters or nothing that also can return the number of rows affected.
You MUST make sure that SET NOCOUNT ON; is not in the stored procedure otherwise -1 will be returned! :)
Awesome, I'll take a look at this now.
Get Outlook for Androidhttps://aka.ms/ghei36
From: mooshpot notifications@github.com Sent: Friday, August 10, 2018 11:47:07 AM To: snickler/EFCore-FluentStoredProcedure Cc: Jeremy Sinclair; Comment Subject: Re: [snickler/EFCore-FluentStoredProcedure] Rows Affected (#22)
I've proposed an update #23https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fsnickler%2FEFCore-FluentStoredProcedure%2Fpull%2F23&data=02%7C01%7C%7Cfd95181a5e7f4284b53e08d5fed88782%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636695128287846073&sdata=IbZjRDAdF6%2FN%2B4iuX1j38cROCW15DwppQ8zQxWfpctQ%3D&reserved=0 which adds two new methods for non-query results i.e. just use SQL output parameters or nothing that also can return the number of rows affected.
You MUST make sure that SET NOCOUNT ON; is not in the stored procedure otherwise -1 will be returned! :)
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fsnickler%2FEFCore-FluentStoredProcedure%2Fissues%2F22%23issuecomment-412123967&data=02%7C01%7C%7Cfd95181a5e7f4284b53e08d5fed88782%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636695128287846073&sdata=1RHwomzU%2FXpg802XTU8QotL3pcrFv7mSdNJaK%2BkcDf0%3D&reserved=0, or mute the threadhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAD1IpYo_-0oXAPexWGR2NSHxS_JG8Ryaks5uPar7gaJpZM4V4GdY&data=02%7C01%7C%7Cfd95181a5e7f4284b53e08d5fed88782%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636695128287846073&sdata=VOvkd4dR1WZBlwGznq%2F3yEi1s%2BGiCiguCmgqJuv0u3I%3D&reserved=0.
Cheers mate! :)
Great, thanks guys!
First off, love this project, thanks for putting it out there.
Here's my question: is there a way to get access to rows affected?
I'm using this in a situation where the sproc is just doing some inserts, but no rows are returned. In this case, SQL Server returns the number of rows affected, but so far I don't see a way to get access to that. It seems like it would be a property on handler:
var result = 0;
db.LoadStoredProc("dbo.sproc_ImportUsers") .WithSqlParam("...", "...") ... .ExecuteStoredProc(handler => { result = handler.RowsAffected });
... Or, perhaps even better, just have ExecuteStoredProc return an int and have an overload that doesn't require the handler parameter:
return db.LoadStoredProc("...").ExecuteStoredProc();
Thanks!