I have scaler function countAbsence
that takes employeeID
as input
I call it as below
int count = db.Database.SqlQuery<int>("SELECT [dbo].[countAbsence](@employeeID)", employeeID).FirstOrDefault();
But I get below exception
System.Data.SqlClient.SqlException (0x80131904): Must declare the scalar variable \"@employeeID\".\r\n
You should specify the parameters using SqlParameter
.
int count = db.Database
.SqlQuery<int>("SELECT [dbo].[countAbsence](@employeeID)", new SqlParameter("@employeeID", employeeID))
.FirstOrDefault();
User contributions licensed under CC BY-SA 3.0