views:

32

answers:

1

I'm experimenting with converting my NHibernate mapping files to FluentNHibernate. However, I'm already stuck on my first attempt. Here's a fragment of one XML mapping file:

<class name="Contact" table="tblXContacts">
  <id       name="_id"                column="ContactID" unsaved-value="0" access="field">
  <generator class="identity"/>
</id>

The default fluent language of FluentNHibernate wants to force me to use properties. While I do expose a type-safe ContactId property for use within the code, I was never able to get NHibernate to accept this value type as the Id, so my public property constructs a new value type on the fly.

I've found that within my FluentNHibernate ClassMap, I can get access to the IdMapping and manipulate its properties directly (e.g. Name, Access) but there's far less documentation on how to do things outside of the fluent builders. For example, how do I set the column? There is "AddColumn(...)", but it wants a ColumnMapping which is where I start to get lost.

+2  A: 

On the fluentnhibernate wiki there is some documentation about mapping private members: http://wiki.fluentnhibernate.org/Fluent_mapping_private_properties. It is about private properties but may be helpful.

Jan Willem B
This also applies to fields as well. The wiki page just hasn't been updated to reflect that yet.
James Gregory
Unfortunately, while that does describe how to handle properties that are private, it doesn't seem to cover how to handle fields.
Trinition