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); } } }
/// <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); }
//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)."); } }
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); }
protected override void ModelMapperOnBeforeMapUnionSubclass(IModelInspector modelInspector, Type type, IUnionSubclassAttributesMapper unionSubclassCustomizer) { unionSubclassCustomizer.Table(GetTableName(modelInspector, type)); }
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) { }
//6.0 TODO: Merge to IUnionSubclassAttributesMapper public static void Extends(this IUnionSubclassAttributesMapper mapper, string entityOrClassName) { ReflectHelper.CastOrThrow <UnionSubclassMapper>(mapper, "Extends(entityOrClassName)").Extends(entityOrClassName); }
private void PluralizeTableName(IModelInspector modelInspector, Type type, IUnionSubclassAttributesMapper unionSubclassCustomizer) { unionSubclassCustomizer.Table(type.Pluralize()); }