我从NHibernate 1.2调用TSQL存储过程。
var q = sessionStrategyNHibernate.GetSession()
.CreateSQLQuery("exec myProc ?, ?, ?, ?")
.SetString(0, "77")
.SetInt32(1, 1)
.SetResultTransformer(new AliasToBeanResultTransformer(typeof(Int16)))
.SetParameter(2, dateMinInclue, NHibernateUtil.DateTime)
.SetParameter(3, dateMaxExclue, NHibernateUtil.DateTime);
var nb = q.UniqueResult<Int16>();
存储过程myProc
返回int(计数)
create procedure myProc
(
@A nvarchar(255),
@B int,
@C datetime,
@D datetime
)
as
begin
select count(*) as NB
from ...
end
go
但每次都会抛出错误
Message : Return types of SQL query were not specified [exec myProc ?, ?, ?, ?]
有什么问题?
答案 0 :(得分:0)
COUNT返回带有32位签名的SQL Server int
。不是Int16