示例#1
0
        void ApplySubClassConvention(IModelInspector mi, Type type, IUnionSubclassAttributesMapper map)
        {
            var tableAttribute = GetAttribute <TableNameAttribute>(type);

            if (tableAttribute != null)
            {
                map.Table(tableAttribute.TableName);
                if (!String.IsNullOrEmpty(tableAttribute.Schema))
                {
                    map.Schema(tableAttribute.Schema);
                }

                return;
            }

            //if the type is nested use the name of the parent
            if (type.DeclaringType != null)
            {
                if (typeof(IContainSagaData).IsAssignableFrom(type))
                {
                    map.Table(type.DeclaringType.Name);
                }
                else
                {
                    map.Table(type.DeclaringType.Name + "_" + type.Name);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Maps an union subclass inheritance hierarchy
        /// </summary>
        /// <param name="modelInspector">The model inspector</param>
        /// <param name="type">The entity type</param>
        /// <param name="mapper">The union subclass mapper</param>
        private void MapUnionSubclass(IModelInspector modelInspector, Type type, IUnionSubclassAttributesMapper mapper)
        {
            Type entityType = type.UnderlyingSystemType;

            string schemaName = namingEngine.ToSchemaName(entityType);
            string tableName  = namingEngine.ToTableName(entityType);

            // Mapping
            mapper.Schema(schemaName);
            mapper.Table(tableName);
        }
示例#3
0
        //6.0 TODO: Merge to IUnionSubclassAttributesMapper<TEntity>
        public static void Extends <TEntity>(this IUnionSubclassAttributesMapper <TEntity> mapper, string entityOrClassName)
            where TEntity : class
        {
            switch (mapper)
            {
            case UnionSubclassCustomizer <TEntity> usc:
                usc.Extends(entityOrClassName);
                break;

            case PropertyContainerCustomizer <TEntity> pcc:
                pcc.CustomizersHolder.AddCustomizer(
                    typeof(TEntity),
                    (IUnionSubclassAttributesMapper m) => m.Extends(entityOrClassName));
                break;

            default:
                throw new ArgumentException($@"{mapper.GetType()} requires to extend {typeof(UnionSubclassCustomizer<TEntity>).FullName} or {typeof(PropertyContainerCustomizer<TEntity>).FullName} to support Extends(entityOrClassName).");
            }
        }
示例#4
0
        void ApplySubClassConvention(IModelInspector mi, Type type, IUnionSubclassAttributesMapper map)
        {
            var tableAttribute = GetAttribute <TableNameAttribute>(type);

            if (tableAttribute != null)
            {
                map.Table(tableAttribute.TableName);
                if (!String.IsNullOrEmpty(tableAttribute.Schema))
                {
                    map.Schema(tableAttribute.Schema);
                }

                return;
            }

            var namingConvention = tableNamingConvention(type);

            map.Table(namingConvention);
        }
示例#5
0
        /// <summary>
        /// Maps an union subclass inheritance hierarchy
        /// </summary>
        /// <param name="modelInspector">The model inspector</param>
        /// <param name="type">The entity type</param>
        /// <param name="mapper">The union subclass mapper</param>
        private void MapUnionSubclass(IModelInspector modelInspector, Type type, IUnionSubclassAttributesMapper mapper)
        {
            Type entityType = type.UnderlyingSystemType;

            string schemaName = namingEngine.ToSchemaName(entityType);
            string tableName = namingEngine.ToTableName(entityType);

            // Mapping
            mapper.Schema(schemaName);
            mapper.Table(tableName);
        }
 protected override void ModelMapperOnBeforeMapUnionSubclass(IModelInspector modelInspector, Type type, IUnionSubclassAttributesMapper unionSubclassCustomizer)
 {
     unionSubclassCustomizer.Table(GetTableName(modelInspector, type));
 }
示例#7
0
 public static void MapUnionSubclass(IModelInspector modelInspector, Type type, IUnionSubclassAttributesMapper map)
 {
 }
 public void InvokeCustomizers(System.Type type, IUnionSubclassAttributesMapper mapper)
 {
     InvokeCustomizers(unionClassCustomizers, type, mapper);
 }
 protected virtual void OnAfterMapUnionSubclass(IModelInspector modelInspector, Type type, IUnionSubclassAttributesMapper unionSubclassCustomizer)
 {
 }
示例#10
0
 //6.0 TODO: Merge to IUnionSubclassAttributesMapper
 public static void Extends(this IUnionSubclassAttributesMapper mapper, string entityOrClassName)
 {
     ReflectHelper.CastOrThrow <UnionSubclassMapper>(mapper, "Extends(entityOrClassName)").Extends(entityOrClassName);
 }
示例#11
0
 private void PluralizeTableName(IModelInspector modelInspector, Type type, IUnionSubclassAttributesMapper unionSubclassCustomizer)
 {
     unionSubclassCustomizer.Table(type.Pluralize());
 }
示例#12
0
 protected virtual void OnAfterMapUnionSubclass(IModelInspector modelInspector, Type type, IUnionSubclassAttributesMapper unionSubclassCustomizer)
 {
 }
 protected override void ModelMapperOnBeforeMapUnionSubclass(IModelInspector modelInspector, Type type, IUnionSubclassAttributesMapper unionSubclassCustomizer)
 {
     unionSubclassCustomizer.Table(GetTableName(modelInspector, type));
 }