Since those event-handler are implemented by you I can say that you have a clear bug that produce duplicated columns names.
On Tue, Apr 19, 2011 at 9:54 AM, Michael DELVA <[email protected]>wrote: > Hello, > > Given these 2 entities: > > public class Match : BaseEntity > { > private Team homeTeam; > private Team roadTeam; > > public Match() > { > } > > public Team HomeTeam > { > get { return homeTeam; } > set > { > if (homeTeam == value) > return; > > if (homeTeam != null) > homeTeam.RemoveFromMatch(this, true); > > homeTeam = value; > > if (value == null) > return; > > value.AddToMatch(this, true); > } > } > > public Team RoadTeam > { > get { return roadTeam; } > set > { > if (roadTeam == value) > return; > > if (roadTeam != null) > roadTeam.RemoveFromMatch(this, false); > > roadTeam = value; > > if (value == null) > return; > > value.AddToMatch(this, false); > } > } > } > > public class Team : BaseEntity > { > public Team() > { > } > } > > And this mapping configuration: > > var mapper = new ConventionModelMapper(); > > var baseEntityType = typeof(BaseEntity); > > mapper.IsEntity((t, declared) => baseEntityType.IsAssignableFrom(t) && > baseEntityType != t && !t.IsInterface); > mapper.IsRootEntity((t, declared) => baseEntityType.Equals(t.BaseType)); > > mapper.BeforeMapManyToOne += (insp, prop, map) => > map.Column(prop.LocalMember.GetPropertyOrFieldType().Name + "Id"); > //mapper.BeforeMapManyToOne += (insp, prop, map) => > map.Cascade(Cascade.Persist); > mapper.BeforeMapManyToOne += (insp, prop, map) => map.NotNullable(true); > //mapper.BeforeMapManyToOne += (insp, prop, map) => > map.Access(Accessor.Field); > > mapper.BeforeMapSet += (insp, prop, map) => map.Key(km => > km.Column(prop.GetContainerEntity(insp).Name + "Id")); > mapper.BeforeMapSet += (insp, prop, map) => map.Cascade(Cascade.All | > Cascade.DeleteOrphans); > mapper.BeforeMapSet += (insp, prop, map) => map.Inverse(true); > > mapper.BeforeMapProperty += (insp, prop, map) => map.NotNullable(true); > > mapper.BeforeMapClass += (i, t, cm) => cm.Id(map => > { > map.Column(t.Name + "Id"); > map.Generator(Generators.Native); > }); > > NH generates this mapping: > > <class name="Match"> > <id name="Id" access="nosetter.camelcase" column="MatchId" type="Int32"> > <generator class="native" /> > </id> > <many-to-one name="HomeTeam" column="TeamId" not-null="true" /> > <many-to-one name="RoadTeam" column="TeamId" not-null="true" /> > </class> > > I expected the mapping to use HomeTeamId and RoadTeamId as column names. > > This can be countered with: > > mapper.Class<Match>(cm => > { > cm.ManyToOne(m => m.HomeTeam, pm => pm.Column("HomeTeamId")); > cm.ManyToOne(m => m.RoadTeam, pm => pm.Column("RoadTeamId")); > }); > > I don't know if this a bug, that's why I ask :) > > Thanks in advance > > Mike > > -- > 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. > -- Fabio Maulo -- 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.
