dragonfly
dragonfly

Reputation: 17773

How to use stored procedures in NHibernate for Create/Update when working with database view

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

Upvotes: 1

Views: 1421

Answers (1)

Stefan Steinegger
Stefan Steinegger

Reputation: 64628

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.

Upvotes: 1

Related Questions