简体   繁体   中英

Fluent NHibernate View Mapping requires Id Column

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...?

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.

mapping.Id(x => x.ID).GeneratedBy.Increment()

但是可能我对这个问题的理解是不正确的。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM