You should be able to do this with a convention: public class AccessAsFieldConvention : IPropertyConvention { public bool Accept(IProperty target) { return true; // or filter on target.EntityType for just specific entities }
public void Apply(IProperty target) { target.Access.AsField(); } } However, there's a big but. You can't get at Access through IProperty, yet; hopefully by the time you're reading this I'll have committed a fix. On Sat, Mar 14, 2009 at 8:05 PM, Mike Chaliy <m...@chaliy.name> wrote: > > Coluld you please give more details. > > I know how to use Access.AsField() on per property basis with > ForTypesThatDeriveFrom, but I do not know how actually to use it with > AutoMapping. > > What I realy try to solve is automapping for "immutable" entities. > Something like this: > > class Test > { > private string name; > public string Name{get{return this.name;}} > } > > On Mar 14, 7:00 pm, James Gregory <jagregory....@gmail.com> wrote: > > You need to use Access.AsField() to inform FNH that the readonly property > is > > backed by a field. > > > > > > > > On Sat, Mar 14, 2009 at 4:48 PM, Mike Chaliy <m...@chaliy.name> wrote: > > > > > In our development we are frequently using readonly properties backed > > > with private fields. > > > > > Is there any way to automap such case? > > > From my walking through code this is impossible to create custom > > > convention just because: > > > > > public virtual void mapEverythingInClass<T> > > > (FluentNHibernate.AutoMap.AutoMap<T> map) > > > { > > > foreach (PropertyInfo property in typeof(T).GetProperties()) > > > { > > > this.TryToMapProperty<T>(map, property); > > > } > > > > > } > > > > > Any thoughts?- Hide quoted text - > > > > - Show quoted text - > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To post to this group, send email to fluent-nhibernate@googlegroups.com To unsubscribe from this group, send email to fluent-nhibernate+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en -~----------~----~----~----~------~----~------~--~---