I am trying to call a stored procedure from entity framework but I am unable to get the output parameter value. It is always returning null. Here is my code
object[] parameters = {
new SqlParameter("@Date", date),
new SqlParameter("@outDate", SqlDbType.Date) {Direction= ParameterDirection.Output}
};
int defval = context.Database.CommandTimeout.Value;
context.Database.CommandTimeout = 1800;
context.Database.ExecuteSqlCommand("dbo.TestDateFormatAndRegion @Date, @outDate", parameters);
var NoOfSyncOperationsDeleted = parameters[1].ToString();
Can you please help.
Thanks
1条答案
按热度按时间zaqlnxep1#
In the
context.Database.ExecuteSqlCommand
call, modified the SQL command to useEXEC
to explicitly execute the stored procedure and addOUTPUT
to the@outDate
parameter.