1

How can I call sp_executesql stored procedure in entity framework? I need to dynamically execute formulas stored in SQL Server table column using Select Statement. I tried ENTITY SQL but it does not work.

0

2 Answers 2

0

Use ObjectContext.ExecuteStoreCommand (requires EF 4).

0

if i understood correctly try this

CREATE PROCEDURE sp_calculatesalary(@EmployeeId as int)  
begin
declare @dynsql varchar(500)=' Salary,Username from employee where EmployeeId=@empID'    
exec sp_executesql @dynsql,'@empID int',@empID=@EmployeeID
SELECT 1 as salary,2 as username
end

it solves stored procedures mapping problem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.