public static void ManyToManyConvention(IModelInspector modelInspector, PropertyPath member, IManyToManyMapper map) { map.ForeignKey( string.Format("fk_{0}_{1}", member.LocalMember.Name, member.GetContainerEntity(modelInspector).Name)); }
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); }
protected override void OnBeforeMapManyToMany(IModelInspector modelInspector, PropertyPath member, IManyToManyMapper collectionRelationManyToManyCustomizer) { collectionRelationManyToManyCustomizer.Column(GetIdentifier(string.Format("{0}Id", member.CollectionElementType().Name))); }
public static void ManyToManyConvention(IModelInspector modelInspector, PropertyPath member, IManyToManyMapper map) { }
private void ManyToManyConvention(IModelInspector modelInspector, PropertyPath member, IManyToManyMapper map) { if (FkConstraintNaming != null) { map.ForeignKey( FkConstraintNaming( member.LocalMember, member.GetContainerEntity(modelInspector))); } }
protected virtual void OnBeforeMapManyToMany(IModelInspector modelInspector, PropertyPath member, IManyToManyMapper collectionRelationManyToManyCustomizer) { }
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"); }
private void ApplyConventions(IModelInspector modelinspector, PropertyPath member, IManyToManyMapper collectionrelationmanytomanycustomizer) { var itemType = member.LocalMember.GetPropertyOrFieldType().DetermineCollectionElementType(); collectionrelationmanytomanycustomizer.Column(itemType.Name + "Id"); }
protected virtual void OnAfterMapManyToMany(IModelInspector modelInspector, PropertyPath member, IManyToManyMapper collectionRelationManyToManyCustomizer) { }
/// <summary> /// Maps a mixed list of columns and formulas. /// </summary> /// <param name="mapper">The mapper.</param> /// <param name="columnOrFormulaMapper">The mappers for each column or formula.</param> /// <remarks>Replaces any previously mapped column or formula.</remarks> public static void ColumnsAndFormulas( this IManyToManyMapper mapper, params Action <IColumnOrFormulaMapper>[] columnOrFormulaMapper) { CallColumnsAndFormulas(mapper, columnOrFormulaMapper); }
/// <summary> /// Maps many formulas. /// </summary> /// <param name="mapper">The mapper.</param> /// <param name="formulas">The formulas to map.</param> /// <remarks>Replaces any previously mapped column or formula.</remarks> public static void Formulas(this IManyToManyMapper mapper, params string[] formulas) { CallFormulas(mapper, formulas); }
public static void FilterSoftDeleted(this IManyToManyMapper mapper) { mapper.Where("[State] = 'Normal'"); }
public void InvokeCustomizers(PropertyPath member, IManyToManyMapper mapper) { InvokeCustomizers(collectionRelationManyToManyCustomizers, member, mapper); }
/// <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); }