예제 #1
0
        public void ApplyMapping(ConventionModelMapper mapper)
        {
            mapper.Class <TicketRelationship>(map => {
                map.ManyToOne(x => x.PrimaryTicket, propMap => {
                    propMap.Column(nameFormatter.GetForeignKeyColumnName(Reflect.Property <TicketRelationship>(x => x.PrimaryTicket)));
                    propMap.ForeignKey(nameFormatter.GetForeignKeyConstraintName(Reflect.Property <TicketRelationship>(x => x.PrimaryTicket), typeof(TicketRelationship)));
                    propMap.Index(nameFormatter.GetIndexName(typeof(TicketRelationship), Reflect.Property <TicketRelationship>(x => x.PrimaryTicket)));
                    propMap.Cascade(Cascade.Persist);
                });

                map.ManyToOne(x => x.SecondaryTicket, propMap => {
                    propMap.Column(nameFormatter.GetForeignKeyColumnName(Reflect.Property <TicketRelationship>(x => x.SecondaryTicket)));
                    propMap.ForeignKey(nameFormatter.GetForeignKeyConstraintName(Reflect.Property <TicketRelationship>(x => x.SecondaryTicket), typeof(TicketRelationship)));
                    propMap.Index(nameFormatter.GetIndexName(typeof(TicketRelationship), Reflect.Property <TicketRelationship>(x => x.SecondaryTicket)));
                    propMap.Cascade(Cascade.Persist);
                });
            });
        }
예제 #2
0
        public void ApplyMapping(ConventionModelMapper mapper)
        {
            mapper.BeforeMapManyToOne += (modelInspector, member, propertyCustomizer) => {
                var parentType = member.LocalMember.GetPropertyOrFieldType();
                var childType  = member.LocalMember.ReflectedType;

                propertyCustomizer.Column(formatter.GetIdentityColumnName(parentType));
                propertyCustomizer.ForeignKey(formatter.GetForeignKeyConstraintName(parentType, childType));
                propertyCustomizer.Index(formatter.GetIndexName(childType, parentType));
                propertyCustomizer.Cascade(Cascade.Persist);
            };
        }