Question

In Fluent NHibernate, References() returns an object which doesn't support the 'ReadOnly()' method.

I'm trying to create this sort of mapping (i.e. one where an update is not propagated to the referred item):

<many-to-one update="false" insert="false" 
name="DestinationSheet" column="DestinationSheetNumber" />

On normal (map()) mappings, those two attributes can be set with ReadOnly().

I'd like to be doing something like this:

References(x => x.DestinationSheet).
       ColumnName("DestinationSheetNumber").ReadOnly();

I can manually add the update and insert attributes using SetAttributes(), and that works fine, but I am concerned that the fact that ReadOnly() is not present on References() is a clue that I shouldn't be trying to do this.

Does anyone know why ReadOnly() is not available in this context?

Was it helpful?

Solution

It's simply not implemented yet. Over time we will come to support all the features of NHibernate, but until then the SetAttribute method is there to allow you to continue.

As an aside, we accept patches!

OTHER TIPS

References creates a many-to-one mapping and according to the documentation, read only is not supported on this mapping. Your approach of setting update and insert to false sounds right to me. AFAIK, the Fluent NHibernate project plans to support all the mapping features of NHibernate, but until then you will have to use SetAttributes.

Implementation of the answer provided by James Gregory is

References(x => x.Store).TheColumnNameIs("StoreId").SetAttribute("update","false");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top