C#

Asked • 07/10/19

How to use DbContext.Database.SqlQuery<TElement>(sql, params) with stored procedure? EF Code First CTP5?

I have a stored procedure that has three parameters and I've been trying to use the following to return the results: context.Database.SqlQuery<myEntityType>("mySpName", param1, param2, param3); At first I tried using `SqlParameter` objects as the params but this didn't work and threw a `SqlException` with the following message: > Procedure or function 'mySpName' expects parameter '@param1', which was not supplied. So my question is how you can use this method with a stored procedure that expects parameters? Thanks.

1 Expert Answer

By:

Sean D. answered • 08/14/20

Tutor
5 (2)

Software Engineer Specializing in C#

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.