Calling a stored procedure with nothing to return using Entity Framework

entity-framework

Question

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?

1
20
6/7/2013 6:30:23 PM

Accepted Answer

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)
);
51
6/7/2013 6:31:11 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow