Entity Framework 6 and output parameter

c# entity-framework entity-framework-6 output stored-procedures

Question

When dealing with EF for the first time in general, I wanted to call a stored procedure. I've added the stored procedure to a model (.edmx), and I think it's calling correctly at this point, but I'm not sure how to add the output parameter.

The saved procedure will accept the following:

CREATE PROCEDURE [dbo].[uspProperty__Read] 
@Skip           INT = NULL,
@Take           INT = NULL,
@OrderBy        VARCHAR(50) = NULL,
@Return_Code        INT = 0 OUTPUT

With the output parameter, I believed I could accomplish this:

  var returnCode = new SqlParameter();
  returnCode.ParameterName = "@ReturnCode";
  returnCode.SqlDbType = SqlDbType.Int;
  returnCode.Direction = ParameterDirection.Output;

  var results = context.uspProperty__Read(10, 10, "NameDesc", out returnCode );

Considering that "uspProperty Read" appears in the intellisense, it appears that I have correctly configured the stored procedure.

Error Message

We would much appreciate any advice. Thanks!

1
0
1/17/2014 2:59:29 PM

Accepted Answer

SqlParameter should be replaced with ObjectParameter.

2
1/17/2014 3:04:20 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