有人知道在Nhibernate中将存储过程准确地映射到哪里吗?
在类hbm.xml文件或新声明的文件(hbm.xml)中,特别是存储过程?
你能讲道理吗??
发布于 2013-03-19 19:45:25
我创建了一个包含所有存储过程调用的XML文件,例如
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<sql-query name="SummaryReport">
exec getSummaryReport :productId
</sql-query>
<sql-query name="FullReport">
exec getFullReport :productId
</sql-query>
</hibernate-mapping>
并将其标记为嵌入式资源。然后我可以这样叫我的SP:-
var results = Session
.GetNamedQuery("SummaryReport")
.SetInt32("productId", productId);
.SetResultTransformer(
new AliasToBeanResultTransformer(typeof(SummaryReport)));
return results.List<SummaryReport>();
这对我来说很好,但真的没有推荐的方法,它总是取决于你觉得对你合适的东西。
https://stackoverflow.com/questions/15491543
复制相似问题