实体框架-存储过程返回值

时间:2018-06-21 06:39:46

标签: c# entity-framework stored-procedures

BEGIN 
SET NOCOUNT ON 

INSERT INTO WSUPPORTTEMP (FIRMRN, FPERSONNAME, SUPPORTTYPEID, FIRMEXPL, USERMAIL, ISENG, REASON ) 
OUTPUT      INSERTED.WRN
VALUES      (@firmrn, @requester, @supportType, @message, @email, @iseng, @reason)
END

我无法使用实体框架6返回输出值。

int x = _context.Database.SqlQuery<int>("i_NewSupportTicket @firmrn, @requester, @supportType, @message, @email, @iseng, @reason", sqParams).First();

我已经尝试过了,但是我无法返回值。

SqlParameter outParam = new SqlParameter
{
    ParameterName = "@wrn",
    Direction = System.Data.ParameterDirection.Output,
    SqlDbType = System.Data.SqlDbType.NVarChar
};
var y = _context.Database.ExecuteSqlCommand("EXEC @wrn = i_NewSupportTicket @firmrn, @requester, @supportType, @message, @email, @iseng, @reason", sqParams);

我有这个例外。

  

SqlException:转换varchar值't'时转换失败   数据类型为int。

我的错在哪里?

0 个答案:

没有答案