/// <summary> /// Generates the name of a component according to the naming conventions configuration /// </summary> /// <param name="parentEntityType">The type of the parent entity</param> /// <param name="componentType">The type of the component</param> /// <param name="relationshipProperty">The property that represents the relationship</param> /// <returns>The component name</returns> public string ToComponentTableName(Type parentEntityType, Type componentType, MemberInfo relationshipProperty) { string result = null; string relationshipPropertyName = relationshipProperty.Name; switch (namingConventions.ComponentsTableNamingConvention) { case ComponentsTableNamingConvention.ComponentName: result = ToTableName(componentType); break; case ComponentsTableNamingConvention.RelationshipName: result = ToTableName(relationshipPropertyName); break; case ComponentsTableNamingConvention.EntityNameComponentName: result = ToTableName(string.Concat(parentEntityType.Name, componentType.Name)); break; case ComponentsTableNamingConvention.EntityNameRelationshipName: result = ToTableName(string.Concat(parentEntityType.Name, relationshipPropertyName)); break; case ComponentsTableNamingConvention.EntityName_ComponentName: result = string.Format(ConventionFormats.RelationshipUnderscoreSeparated, ToTableName(parentEntityType), ToTableName(componentType)); break; case ComponentsTableNamingConvention.EntityName_RelationshipName: result = string.Format(ConventionFormats.RelationshipUnderscoreSeparated, ToTableName(parentEntityType), ToTableName(relationshipPropertyName)); break; case ComponentsTableNamingConvention.Custom: { if (namingConventions.ComponentsCustomTableNamingConvention == null) { throw new ConfigurationErrorsException(string.Format(ExceptionMessages.CustomConventionNotFound, typeof(ComponentsTableNamingConvention).Name)); } result = namingConventions.ComponentsCustomTableNamingConvention(parentEntityType, componentType, relationshipProperty); }; break; } return(result); }