Does NHibernate support mapping of SQL VIEWS? Any examples would be helpful.
+4
A:
Yes, just use your view name instead of the table name in your mapping config. Of course it will throw an exception if you try to update though.
e.g.:
<class name="someclass" table="vw_someview">
...
</class>
UpTheCreek
2010-09-29 14:01:10
+1
A:
The simple answer is: Yes.
Just put your view's name in the places where normally in all the examples is written a table name. That's it. Views and tables are interchangeable - as long as the view is writeable without constraints...
Thomas
Thomas Weller
2010-09-29 14:10:09
+1
A:
Yes. You can update or insert to views in SQL Server if certain conditions are met, see the Updateable Views section in the documentation. I know this applies to SQL Server 2005+, I don't know about earlier versions.
If the view is not updateable, you can declare the mapping as read-only.
Jamie Ide
2010-09-29 14:57:57