コード例 #1
0
 public static void ManyToManyConvention(IModelInspector modelInspector, PropertyPath member, IManyToManyMapper map)
 {
     map.ForeignKey(
         string.Format("fk_{0}_{1}",
                member.LocalMember.Name,
                member.GetContainerEntity(modelInspector).Name));
 }
コード例 #2
0
        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)));
 }
コード例 #4
0
 public static void ManyToManyConvention(IModelInspector modelInspector, PropertyPath member, IManyToManyMapper map)
 {
     map.ForeignKey(
         string.Format("fk_{0}_{1}",
                       member.LocalMember.Name,
                       member.GetContainerEntity(modelInspector).Name));
 }
コード例 #5
0
 public static void ManyToManyConvention(IModelInspector modelInspector, PropertyPath member, IManyToManyMapper map)
 {
 }
コード例 #6
0
ファイル: NamingConvention.cs プロジェクト: Lionhunter3k/nHL
 private void ManyToManyConvention(IModelInspector modelInspector, PropertyPath member, IManyToManyMapper map)
 {
     if (FkConstraintNaming != null)
     {
         map.ForeignKey(
             FkConstraintNaming(
                 member.LocalMember,
                 member.GetContainerEntity(modelInspector)));
     }
 }
コード例 #7
0
 protected virtual void OnBeforeMapManyToMany(IModelInspector modelInspector, PropertyPath member, IManyToManyMapper collectionRelationManyToManyCustomizer)
 {
 }
 protected override void OnBeforeMapManyToMany(IModelInspector modelInspector, PropertyPath member, IManyToManyMapper collectionRelationManyToManyCustomizer)
 {
     collectionRelationManyToManyCustomizer.Column(GetIdentifier(string.Format("{0}Id", member.CollectionElementType().Name)));
 }
		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");
		}
コード例 #10
0
ファイル: ManyToMany.cs プロジェクト: solyutor/enhima
 private void ApplyConventions(IModelInspector modelinspector, PropertyPath member, IManyToManyMapper collectionrelationmanytomanycustomizer)
 {
     var itemType = member.LocalMember.GetPropertyOrFieldType().DetermineCollectionElementType();
     collectionrelationmanytomanycustomizer.Column(itemType.Name + "Id");
 }
コード例 #11
0
 protected virtual void OnAfterMapManyToMany(IModelInspector modelInspector, PropertyPath member, IManyToManyMapper collectionRelationManyToManyCustomizer)
 {
 }
コード例 #12
0
 /// <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);
 }
コード例 #13
0
 /// <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);
 }
コード例 #14
0
 public static void FilterSoftDeleted(this IManyToManyMapper mapper)
 {
     mapper.Where("[State] = 'Normal'");
 }
コード例 #15
0
 public void InvokeCustomizers(PropertyPath member, IManyToManyMapper mapper)
 {
     InvokeCustomizers(collectionRelationManyToManyCustomizers, member, mapper);
 }
コード例 #16
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);
        }
コード例 #17
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);
        }