【发布时间】:2018-04-16 14:43:30
【问题描述】:
我想在 NHibernate 中执行一个简单的 MySQL 存储过程调用,如下所示:
public void ExecuteProcedure(long idCell)
{
using (ISession session = this.iSessionFactory.OpenSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
try
{
string sQL = "call test(:idCell)";
IQuery query = session.CreateSQLQuery(sQL);
query.SetParameter("idCell", idCell);
query.UniqueResult();
}
catch (Exception ex)
{
transaction.Rollback();
}
}
}
}
下面是存储过程:
CREATE PROCEDURE `test`(IN `testing` BIGINT)
LANGUAGE SQL
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
select * from tbcell where id = testing;
END
这会返回以下错误:
could not execute query
[ call test(?p0); ]
Name:idCell - Value:18
[SQL: call test(?p0);]
怎么了?感谢您的帮助。
【问题讨论】:
-
你能显示错误详情吗?
-
感谢您关注纳杰拉。不幸的是,错误窗口中没有更多细节。
-
这个命令(理论上)正确吗?还是有最好的方法来做到这一点?
标签: c# mysql stored-procedures nhibernate