试试这个,你的映射: -
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<sql-query name="SummaryReport">
exec getSummaryReport :productId
</sql-query>
</hibernate-mapping>
然后使用 SetResultTransformer...
var results = Session
.GetNamedQuery("SummaryReport")
.SetInt32("productId", productId);
.SetResultTransformer(new AliasToBeanResultTransformer(typeof(YOURCLASS)));
return results.List<YOURCLASS>();
你的班级是:-
public class YOURCLASS
{
public virtual int ProductId { get; set; }
public virtual string Column1Returned { get; set; }
public virtual int Column2Returned { get; set; }
etc..
}
确保从您的 SP 返回的内容定义为YOURCLASS
记住您的列名和属性名必须完全匹配,因为它们是CASE
敏感的。