4

How can I map to a private field with fluent NHibernate AutoPersistenceModel?

    public class A
    {
        private List<B>  myField;

        public A()
        {
            myField = new List<B>();
        }

        public IList<B> MyBs
        {
            get { return myField; }
        }
    }

Is there a fieldconvention for the AutoPersistence model or do I have to use separate mappings for classes with fields?

Paco
  • 8,335
  • 3
  • 30
  • 41

3 Answers3

1

The answer:

It's not possible yet. Maybe I should submit a patch for it...

Paco
  • 8,335
  • 3
  • 30
  • 41
0

I know this is not does not answer the auto mapping, but to assist those who get this searching for private field mapping.

You can now use the following code:

public class A
{
    private List<B>  myBs;

    public A()
    {
        myField = new List<B>();
    }

    public IList<B> MyBs
    {
        get { return myField; }
    }
}

With a mapping like this

public class AMap : ClassMap<A> {
        public AMap() {
            HasMany(x => x.MyBs).Access.CamelCaseField()
        }
}
Mike Glenn
  • 3,359
  • 1
  • 26
  • 33
-2

It's been a while since this question was asked, but it's probably worth posting this answer in case others find this question.

The Fluent NHibernate Wiki has some information on 3 possible workarounds.

http://wiki.fluentnhibernate.org/Fluent_mapping_private_properties

RR.
  • 679
  • 4
  • 8
  • 1
    That is not about automapping, but about manual mapping. I knew that before asking the question. – Paco Oct 21 '09 at 19:03