Paul and Anthony T.,
Apologies but I am a little confused by the discussion regarding
above. I just want to see if I can understand this for my own
edification.
Paul, when a class contains an Id field instead of a property, I
assume that NHibernate will not map it since fields cannot be virtual.
I am unfamiliar with the AsField() method. It looks the AsField() is
just a workaround to allow you to map a field. However, I think I am
understanding that while this can be used to map most fields, AsField
() can not be used in place of the primary Id property. You seem to be
suggesting that with some of your further refactoring, that you may
modify this behavior. Is this correct?
Anthony T., I am just curious, is there a technical reason why you may
not want to the change fields to properties? I understand that for
rare cases (e.g. high frequency loops), a field may offer a
performance benefit. However for 99% of cases, most developers prefer
properties. For items without default values, declaring a property or
a field (in.NET 3.x) requires virtually the same effort.
Field: public int Id;
Property: public int Id { get; set; }
(Oh crap. I just stepped into a pile of droppings from the fields vs.
properties debate.)
On Sep 13, 2:26 am, Paul Batum <
paul.ba...@gmail.com> wrote:
> Hi Anthony,
>
> Unfortunately, fluent nhibernate doesn't yet support direct mapping of
> fields. This is because there is significant chunk of code that works with
> PropertyInfos that we haven't managed to revisit yet. You can use AsField()
> when you have a property that exposes a field and you want NHibernate to set
> the field directly, but this does not help your case where all you have is a
> public field. I am afraid that unless there is a workaround that I'm unaware
> of, you will have to map your entity manually with xml.
>
> Paul Batum
>