Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling a stored procedure with nothing to return using Entity Framework

Tags:

I understand this is the way we call a stored procedure using Entity Framework.

context.Database.SqlQuery<myEntityType>(     "mySpName @param1, @param2, @param3",     new SqlParameter("param1", param1),     new SqlParameter("param2", param2),     new SqlParameter("param3", param3) ); 

But, what if my stored procedure only a has couple of update statements and does not return anything, what should I put instead of myEntityType?

like image 325
sunil Avatar asked Jun 07 '13 18:06

sunil


1 Answers

You want context.Database.ExecuteSqlCommand instead of SqlQuery

context.Database.ExecuteSqlCommand(     "mySpName @param1, @param2, @param3",     new SqlParameter("param1", param1),     new SqlParameter("param2", param2),     new SqlParameter("param3", param3) ); 
like image 197
Matt Davies Avatar answered Oct 25 '22 10:10

Matt Davies