Hello All,
I am trying to call a stored procedure using entity framework core. The stored procedure is little bit complicated so I am not using LINQ. Below is my code:
using(IdentityProofContext dc = new IdentityProofContext())
{
SqlParameter[] @params =
{
new SqlParameter("@result", SqlDbType.Int) {Direction = ParameterDirection.Output}
};
dc.IdentityPersonalData.FromSqlRaw("Execute usp_GetIdentityProofStatus", @params).FirstOrDefaultAsync();
var result1 = dc.IdentityPersonalData.FromSqlInterpolated($"EXEC usp_GetStatus").ToListAsync().Result;
//var result = @params[0].Value;
//if (result > 0)
//{
// MiscEmails.sendEmails();
//}below is my stored procedure:
alter Procedure usp_GetStatus
(
@result int OUTPUT
)
AS
SELECT @result = COUNT(*)
FROM dbo.TestData
WHERE DATEDIFF(MINUTE, DateInserted, GETDATE()) < 120 --Number of minutes
AND STATUS IN ('test1' )
return @resultThese are the two different lines of code that I am trying , I am using to call the stored procedure and both of them are throwing exception.
dc.IdentityPersonalData.FromSqlRaw("Execute usp_GetIdentityProofStatus", @params).FirstOrDefaultAsync();
var result1 = dc.IdentityPersonalData.FromSqlInterpolated($"EXEC usp_GetIdentityProofStatus").ToListAsync().Result;any help will be highly appreciated.