views:

250

answers:

3

Hi

Trying to use FNH to map a view - FNH insists on having a Id property mapped. However not all of my views have a unique identifing column.

I can get around this with XML mappings as I can just specify a

<id type="int">  
   <generator class="increment"/>  
</id>

at the top of the mapping.

Is there any way to duplicate this in FNH...?

TIA

Matt

A: 

Pretty sure the view has to be indexable which I haven't done in some time, but I recall it involves setting up composite keys and ensuring the view can be SchemaBound. Then in the FNH mapping you would specify the table name (which you probably already are) and the UseCompositeId method.

mannish
Seems slightly overkill when standard NH does what I need - it's more a question of how to get FNH to duplicate the standard behaviour. Thanks anyway though.
Matt
Depends on what you're trying to accomplish, and for a read-only scenario, it is overkill. The other option is to simply map your views in xml and skip FNH for those specific entities.
mannish
A: 
mapping.Id(x => x.ID).GeneratedBy.Increment()

But probably, my understanding of the question is incorrect.

Mike Chaliy
Thanks mike, but the issue is that in the x => x.ID, my entity class does not have an ID property. I did try an empty lambda (x=>{}) but that didn't work either. Cheers though!
Matt
A: 

At the time I asked the question, this wasn't supported in Fluent NHibernate. One of the developers added it as feature, and we are evaluating it at the moment.

Matt

Matt