src/Misc/EFTools/EntityDesignModel/ModelHelper.cs
/// <summary>
///     Produces a property name that does not exist in the given entity type
///     A suffix is added to given candidate name to make it unique if necessary
/// </summary>
/// <param name="propertyNameCandidate">Candidate property name</param>
/// <param name="entityType">Entity type in which the property name should be unique</param>
/// <param name="namesToAvoid">Entity type in which the property name should be unique</param>
/// <param name="childEFObjectsToIgnore">Entity type in which the property name should be unique</param>
/// <param name="alwaysAddSuffix">Entity type in which the property name should be unique</param>
/// <returns>Unique property name</returns>
Produces a property name that does not exist in the given entity type
A suffix is added to given candidate name to make it unique if necessary
Produces a property name that does not exist in the given entity type A suffix is added to given candidate name to make it unique if necessary
internal static string GetUniqueConceptualPropertyName(
            string propertyNameCandidate, EntityType entityType, HashSet<string> namesToAvoid = null,
            HashSet<EFObject> childEFObjectsToIgnore = null, bool alwaysAddSuffix = false)
        {
            Debug.Assert(
                EscherAttributeContentValidator.IsValidCsdlPropertyName(
                    alwaysAddSuffix ? propertyNameCandidate + DefaultPropertySuffixSeed : propertyNameCandidate),
                    "Candidate property name is not valid");
            var cEntityType = entityType as ConceptualEntityType;
            Debug.Assert(cEntityType != null, "Why isn't the entity type a conceptual entity type?");
            var allDistinctPropertyNamesInInheritanceTree =
                (from p in cEntityType.SafePropertiesInInheritanceHierarchy
                 select p.LocalName.Value).Distinct();
            namesToAvoid = namesToAvoid != null ? 
                new HashSet<string>(namesToAvoid.Union(allDistinctPropertyNamesInInheritanceTree)) : 
                new HashSet<string>(allDistinctPropertyNamesInInheritanceTree);
            var propertyName = GetUniquePropertyName(
                propertyNameCandidate, entityType, namesToAvoid, childEFObjectsToIgnore,
                alwaysAddSuffix ? DefaultPropertySuffixSeed : (int?)null);
            Debug.Assert(
                EscherAttributeContentValidator.IsValidCsdlPropertyName(propertyName),
                "ModelHelper.GetUniqueConceptualPropertyName(): Generated non-valid unique property name");
            return propertyName;
        }
internal static string GetUniqueConceptualPropertyName ( string propertyNameCandidate , EntityType entityType , HashSet < string > namesToAvoid = null , HashSet < EFObject > childEFObjectsToIgnore = null , bool alwaysAddSuffix = false ) { Debug . Assert ( EscherAttributeContentValidator . IsValidCsdlPropertyName ( alwaysAddSuffix ? propertyNameCandidate + DefaultPropertySuffixSeed : propertyNameCandidate ) , " " ) ; var cEntityType = entityType as ConceptualEntityType ; Debug . Assert ( cEntityType != null , " " ) ; var allDistinctPropertyNamesInInheritanceTree = ( from p in cEntityType . SafePropertiesInInheritanceHierarchy select p . LocalName . Value ) . Distinct ( ) ; namesToAvoid = namesToAvoid != null ? new HashSet < string > ( namesToAvoid . Union ( allDistinctPropertyNamesInInheritanceTree ) ) : new HashSet < string > ( allDistinctPropertyNamesInInheritanceTree ) ; var propertyName = GetUniquePropertyName ( propertyNameCandidate , entityType , namesToAvoid , childEFObjectsToIgnore , alwaysAddSuffix ? DefaultPropertySuffixSeed : ( int ? ) null ) ; Debug . Assert ( EscherAttributeContentValidator . IsValidCsdlPropertyName ( propertyName ) , " " ) ; return propertyName ; }
Produces a property name that does not exist in the given entity type
A suffix is added to given candidate name to make it unique if necessary
Produces a property name that does not exist in the given entity type A suffix is added to given candidate name to make it unique if necessary
Unique property name
Unique property name
propertyNameCandidate
string
Candidate property name
Candidate property name
entityType
EntityType
Entity type in which the property name should be unique
Entity type in which the property name should be unique
namesToAvoid
HashSet<string>
Entity type in which the property name should be unique
Entity type in which the property name should be unique
childEFObjectsToIgnore
HashSet<EFObject>
Entity type in which the property name should be unique
Entity type in which the property name should be unique
alwaysAddSuffix
bool
Entity type in which the property name should be unique
Entity type in which the property name should be unique