protected void BeforeMapManyToMany(IModelInspector modelInspector, PropertyPath member, IManyToManyMapper collectionRelationManyToManyCustomizer)
        {
            collectionRelationManyToManyCustomizer.Lazy(LazyRelation.Proxy);
            Type destinationType = member.LocalMember.GetPropertyOrFieldType().GetGenericArguments()[0];

            collectionRelationManyToManyCustomizer.Column(this.GetNormalizedDbName(String.Concat(destinationType.Name, "ID")));
            collectionRelationManyToManyCustomizer.Class(destinationType);
        }
Exemple #2
0
        /// <summary>
        /// Maps a many to many relationship
        /// </summary>
        /// <param name="modelInspector">The model inspector</param>
        /// <param name="property">The property to map</param>
        /// <param name="mapper">The property mapper</param>
        private void MapManyToMany(IModelInspector modelInspector, PropertyPath property, IManyToManyMapper mapper)
        {
            Type sourceType = property.LocalMember.DeclaringType;
            Type targetType = property.LocalMember.GetPropertyOrFieldType().DetermineCollectionElementType();

            var    primaryKeyProperty   = modelInspector.GetIdentifierMember(targetType);
            var    foreignKeyProperty   = property.LocalMember;
            string foreignKeyColumnName = namingEngine.ToManyToManyForeignKeyColumnName(targetType, primaryKeyProperty);
            string foreignKeyName       = namingEngine.ToManyToManyForeignKeyName(sourceType, targetType, targetType, primaryKeyProperty);

            mapper.Column(foreignKeyColumnName);
            mapper.ForeignKey(foreignKeyName);
        }
        /// <summary>
        /// Maps a many to many relationship
        /// </summary>
        /// <param name="modelInspector">The model inspector</param>
        /// <param name="property">The property to map</param>
        /// <param name="mapper">The property mapper</param>
        private void MapManyToMany(IModelInspector modelInspector, PropertyPath property, IManyToManyMapper mapper)
        {
            Type sourceType = property.LocalMember.DeclaringType;
            Type targetType = property.LocalMember.GetPropertyOrFieldType().DetermineCollectionElementType();

            var primaryKeyProperty = modelInspector.GetIdentifierMember(targetType);
            var foreignKeyProperty = property.LocalMember;
            string foreignKeyColumnName = namingEngine.ToManyToManyForeignKeyColumnName(targetType, primaryKeyProperty);
            string foreignKeyName = namingEngine.ToManyToManyForeignKeyName(sourceType, targetType, targetType, primaryKeyProperty);

            mapper.Column(foreignKeyColumnName);
            mapper.ForeignKey(foreignKeyName);
        }
 protected override void OnBeforeMapManyToMany(IModelInspector modelInspector, PropertyPath member, IManyToManyMapper collectionRelationManyToManyCustomizer)
 {
     collectionRelationManyToManyCustomizer.Column(GetIdentifier(string.Format("{0}Id", member.CollectionElementType().Name)));
 }
Exemple #5
0
 private void ApplyConventions(IModelInspector modelinspector, PropertyPath member, IManyToManyMapper collectionrelationmanytomanycustomizer)
 {
     var itemType = member.LocalMember.GetPropertyOrFieldType().DetermineCollectionElementType();
     collectionrelationmanytomanycustomizer.Column(itemType.Name + "Id");
 }
		protected virtual new void BeforeMapManyToMany(IModelInspector modelInspector, PropertyPath member, IManyToManyMapper collectionRelationManyToManyCustomizer)
		{
			Type destinationEntityType = member.LocalMember.GetPropertyOrFieldType().GetGenericArguments().First();
			//set the mapping table column names from each source entity name plus the _Id sufix
			collectionRelationManyToManyCustomizer.Column(destinationEntityType.Name + "_Id");
		}
 protected override void OnBeforeMapManyToMany(IModelInspector modelInspector, PropertyPath member, IManyToManyMapper collectionRelationManyToManyCustomizer)
 {
     collectionRelationManyToManyCustomizer.Column(GetIdentifier(string.Format("{0}Id", member.CollectionElementType().Name)));
 }