使用数据库视图时如何在NHibernate中使用存储过程进行创建/更新 [英] How to use stored procedures in NHibernate for Create/Update when working with database view
问题描述
我在表周期上有一个SQL Server视图 CyclesList . Cycle 表包含几列,并且 CyclesList 视图添加了一些可以在数据库级别计算的数据.
现在,我有一个NHibernate映射,它指向 CyclesList :
<class name="Cycle" table="CyclesList">
但是,我仍然想使用 Cycle 类并执行创建/更新操作,但是我必须使用将直接访问 Cycle 表的存储过程.有没有办法在NHibernate中实现它?我会申请一个示例映射/链接到带有示例的资源.谢谢
您可以在文档中的用于创建,更新和删除的自定义SQL".基本上,您需要在映射文件中包含"sql-insert","sql-delete"和"sql-update"元素.
在Ayendes博客上也有一个示例. /p>
I have a SQL Server view CyclesList on the table Cycle. Cycle table contains a few columns, and CyclesList view add some more data that can be computed on database level.
And now, I have a NHibernate mapping that points to CyclesList:
<class name="Cycle" table="CyclesList">
However, I would still like to work with Cycle class, and perform Create/Update operations , but I have to use stored procedure that will access Cycle table directly. Is there a way to achieve it in NHibernate? I would appriciate a sample mapping/links to resources with samples. Thanks
You find some information in the docs under "Native-Sql -> Custom SQL for create, update and delete". Basically, you need the "sql-insert", "sql-delete" and "sql-update" elements in the mapping file.
There is also an example on Ayendes blog.
这篇关于使用数据库视图时如何在NHibernate中使用存储过程进行创建/更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!