ASP.NET MVC EF中调用MySQL的存储过程OUT参数 [英] ASP.NET MVC EF Calling MySQL Stored Procedure with Out Parameters

查看:2096
本文介绍了ASP.NET MVC EF中调用MySQL的存储过程OUT参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用实体框架ExecuteStoreQuery调用与输出参数MySQL的存储过程。该存储过程也返回结果集。

我碰到下面的错误。

OUT或INOUT参数2例行mydb.mysp是不是在BEFORE触发器变量或新的伪变量

什么是错的?有没有更好的方法来调用MySql的SP与OUT参数,并搭配结果集?

这里是code

  VAR outParam =新了MySQLParameter();
                outParam.ParameterName =totalRowsOut;
                outParam.MySqlDbType = MySqlDbType.Int64;
                outParam.Direction = ParameterDirection.Output;VAR数据= db.ExecuteStoreQuery< PropertySearchResultRow>

    呼mysp(@输入1,@totalRowsOut);,
    新了MySQLParameter(输入1,10)
    outParam
);VAR的结果= data.ToList();
INT totalRowsCount =(INT)outParam.Value;


解决方案

终于结束了使用ado.net的MySqlCommand调用存储过程并获得了价值。 MySQL和EF集成是坏的。

I am using Entity Framework ExecuteStoreQuery to call a MySql stored procedure with output parameter. The store procedure also returns a result set.

I get the following error.

OUT or INOUT argument 2 for routine mydb.mysp is not a variable or NEW pseudo-variable in BEFORE trigger

What is wrong? Is there a better way to call MySql sp with mix of out params and resultset?

Here is the code

     var outParam = new MySqlParameter();
                outParam.ParameterName = "totalRowsOut";
                outParam.MySqlDbType = MySqlDbType.Int64;
                outParam.Direction = ParameterDirection.Output;

var data =  db.ExecuteStoreQuery<PropertySearchResultRow>
(
    "call mysp(@input1, @totalRowsOut);", 
    new MySqlParameter("input1", 10),
    outParam
);

var result = data.ToList();
int totalRowsCount = (int)outParam.Value;

解决方案

Finally ended up using the ado.net MySqlCommand to call the stored proc and get the out value. Mysql and EF integration is bad.

这篇关于ASP.NET MVC EF中调用MySQL的存储过程OUT参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆