views:

53

answers:

0

I can have a nested component on a one to one like this:

    Component(a => a.XPTO, m =>
                  {
                      m.Map(xpto => xpto.X, "X").Not.Nullable();
                      m.Component(xpto => xpto.Y, m2 =>
                                               {
                                                  m2.Map(y=> y.Y1, "Y1").Not.Nullable();
                                                  m2.Map(y=> y.Y2, "Y2").Not.Nullable();
                                                }
                                 );
                  });

But if i have a ClassA that has a IList< ClassB > property BList, and ClassB has a ClassC property, C, with properties C1 and C2, and i do this:

    HasMany(p => p.BList).Component(m =>
                            {
                                //compile error:
                                m.Component(b => b.C, m2 =>
                                   {
                                      m2.Map(c => c1, "C1").Not.Nullable();
                                      m2.Map(c => c2, "C2").Not.Nullable();
                                   }
                                 )
                           }

it fails because it doesnt accept component in that context.

I found an ugly workaround, which is to expose C properties C1 and C2 in B, like this for example for C1:

public decimal C1
{
     get {return this.C.C1;}
     set {this.C.C1 = value;}
}

and then use the Map:

HasMany(p => p.BList).Component(m =>
                                      {

                                          m.Map(b => b.C1,"C1"); 

                                          m.Map(b => b.C2,"C2"); 
                                      }

this works but is ugly. Can anyone give me a better solution? Thanks