Stored Procedure call using WebApi EntityFrameWorkCore 1.1 gets and object not the integer results
I have the following user defined procedure to call a calculated data from database with 2 parameters to return an integer (Count(*))
USE [QIIS2]
GO
PROCEDURE [dbo].[sp.GetCansTotals]
@hospitalId int
AS
BEGIN
SET NOCOUNT ON;
SELECT COUNT(*) AS TotalCancelled
FROM Cans
WHERE hospitalId = @hospitalId;
END
The repository to call the procedure:
public async Task GetCansTotals(int hospitalId)
{
using (appContext)
{
var hospitalid = new SqlParameter("@hospitalId", 1);
var cans = appContext.Cans.FromSql("Exec GetCansTotals @hospitalId", hospitalId);
}
}
and the controller:
[HttpGet("byParams")]
public IActionResult GetCanTotal(int hospitalId)
{
var res = _unitOfWork.Cans.GetCansTotals(hospitalId);
return Ok(res);
}
When passing the request with postman:
http://localhost:56963/api/cansdatas/byParams?hospitalId=2 I get an object rather than the results of COUNT(*)
{
"result": {},
"id": 1,
"exception": null,
"status": 5,
"isCanceled": false,
"isCompleted": true,
"creationOptions": 0,
"asyncState": null,
"isFaulted": false
}
Can you help please?