16

It's possible to map a VIEW using Fluent NHibernate? If so, how?

rguerreiro
  • 2,673
  • 3
  • 22
  • 23

2 Answers2

19

I would think you could just replace your the table name with your view name using the WithTable method:

WithTable("myview");

Edit: Just to update this answer, Fluent NHibernate now uses:

Table("myview");
Phill
  • 18,398
  • 7
  • 62
  • 102
mxmissile
  • 11,464
  • 3
  • 53
  • 79
3

mxmissile's answer is correct but I wanted to add that the view will have to be updateable (SQL Server term.) if you want to do inserts or updates against it. I have several tables mapped against views that filter out inactive records because these tables allow soft deletes.

Jamie Ide
  • 48,427
  • 16
  • 81
  • 117
  • 1
    If I recall, these "updateable" views are title Indexed Views? It's been awhile since I had to deal with this stuff. – mxmissile May 12 '09 at 22:04