Mapping by code and access

20 views
Skip to first unread message

Niclas Pehrsson

unread,
Aug 9, 2011, 4:18:29 AM8/9/11
to nhusers
Hi we are evaluating the new mapping by code features, and we does not
succeeding with creating a default access strategy for Id, we are
unfortunately using VB.NET in this project so the example code will be
in VB.NET.

AddHandler _mapper.BeforeMapClass, Sub(modelInspector As
IModelInspector, type As Type, classCustomizer As
IClassAttributesMapper)

classCustomizer.Lazy(False)

classCustomizer.Id(Sub(idMapper As IIdMapper)

idMapper.Access(Accessor.Field)

idMapper.Generator(Generators.GuidComb)

End Sub)
End Sub

It seems like the access strategy is ignored
(NHibernate.PropertyNotFoundException: Could not find a setter for
property 'Id' in class).

We are also trying to figure out how to choose camelcase-underscore
strategy

Any ideas that would help us solve our problems?

Niclas Pehrsson

unread,
Aug 9, 2011, 4:26:36 AM8/9/11
to nhu...@googlegroups.com
We may have figured it out, we thought we could use this as convention over configuration methodology but when we in our mapping called
            _mapper.Class(Of MeasurementConfiguration)(Sub(entity)
                                                           '   entity.Id(Function(x) x.Id)
                                                       End Sub)
will override all settings we made in the beforemapclass id setter.

And it seems that camelcase-underscore is the standard name strategy.

Fabio Maulo

unread,
Aug 9, 2011, 8:48:40 AM8/9/11
to nhu...@googlegroups.com
no is not.
When you say "Access.Field" NH will autodiscover the fieldname using all embedded strategies.
Reply all
Reply to author
Forward
0 new messages