So, I'm trying to execute a SP from Entity Framework 6 and return the output parameter @AffectedRowCount that holds the number of rows that were affected by the execution. Below is my code and a screenshot of the SSMS execution showing the correct result. rowCount.Value is null everytime it executes through C# even after I reset the data. Any thoughts.
public int UpdateStagingTable()
{
var rowCount = new ObjectParameter("AffectedRowCount", typeof(Int32));
be.sp_LoanCategoryMonitor(rowCount);
return Convert.ToInt32(rowCount.Value);
}
This is the autogened Code from the dbContext
public virtual ObjectResult<sp_LoanCategoryMonitor_Result> sp_LoanCategoryMonitor(ObjectParameter affectedRowCount)
{
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<sp_LoanCategoryMonitor_Result>("sp_LoanCategoryMonitor", affectedRowCount);
}
SSMS Execution
DECLARE @return_value int,
@AffectedRowCount int
EXEC @return_value = [dbo].[sp_LoanCategoryMonitor]
@AffectedRowCount = @AffectedRowCount OUTPUT
SELECT @AffectedRowCount as N'@AffectedRowCount'
SELECT 'Return Value' = @return_value
SSMS Results