Hi Guys

 

I think I have found a bug with the mapping by code:-

 

Given the following domain:

 

public class CmsTemplate : Entity { 

       public virtual string Template { get; set; }

       public virtual IList<CmsRegion> RegionList{ get; protected set; }

}

 

And the following mapping file

 

public class CmsTemplateMapping : EntityMapping<CmsTemplate> {

  public CmsTemplateMapping() {

    Property(x => x.Template, x => x.NotNullable(true));

      Bag(x => x.RegionList, x => {

          x.Key(k => k.Column("TemplateId")); 

          x.Table("cmstemplateregion");

        },

         a => a.ManyToMany(x => { x.Class(typeof (CmsRegion));
x.Column("RegionId"); })

      );

  }

}

 

When I use the following configuration code

 

var mapper = new ModelMapper();

mapper.AddMappings(typeof(CmsMeta).Assembly.GetTypes());

var configure = new Configuration();

configure.DataBaseIntegration(x =>

{

  x.Dialect<MySQL5Dialect>();

  x.ConnectionStringName = "db";

}).CurrentSessionContext<WebSessionContext>();

 

var mapping = mapper.CompileMappingForAllExplicitlyAddedEntities();

var mappingXml = mapping.AsString();

configure.AddDeserializedMapping(mapping, "Domain");

 

I get  the following HBM:-

 

<bag name="RegionList" table="cmstemplateregion">

  <key column="TemplateId" />

  <many-to-many class="CmsRegion" column="RegionId" /> Notice many-to-many

</bag>

 

This is the correct XML, however when I introduce a model inspector class
and use:-

 

var modelInspector = new MyModelInspector();

var mapper = new ModelMapper(modelInspector);

 

public class MyModelInspector : ExplicitlyDeclaredModel {

  public override bool IsOneToMany(MemberInfo member) {

    if (IsBag(member)){

      return true;

    }

    return base.IsOneToMany(member);

  }

}

 

I get the following incorrect XML

 

<bag name="RegionList" table="cmstemplateregion">

      <key column="TemplateId" />

      <one-to-many class="CmsRegion" /> Notice the one-to-many

    </bag>

 

Can anyone conform that this is a bug, or is it something I am doing wrong?

 

Many thanks

Rippo

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to