src/Misc/EFTools/EntityDesignDatabaseGeneration/MetadataWorkspaceExtensions.cs
/// <summary>
///     Obtains the StoreGeneratedPattern value of an EdmProperty, given a target version and DataSpace
/// </summary>
/// <param name="property">The EdmProperty.</param>
/// <param name="targetVersion">Used to correctly look up the StoreGeneratedPattern value in the EdmProperty</param>
/// <param name="dataSpace">DataSpace where the EdmProperty lives (either CSDL or SSDL)</param>
/// <returns>One of the StoreGeneratedPattern values, or String.Empty if the attribute or value does not exist</returns>
Obtains the StoreGeneratedPattern value of an EdmProperty, given a target version and DataSpace
Obtains the StoreGeneratedPattern value of an EdmProperty given a target version and DataSpace
public static StoreGeneratedPattern GetStoreGeneratedPatternValue(
            this EdmMember property, Version targetVersion, DataSpace dataSpace)
        {
            if (targetVersion == null)
            {
                throw new ArgumentNullException("targetVersion");
            }
            if (dataSpace == DataSpace.CSSpace
                || dataSpace == DataSpace.OCSpace
                || dataSpace == DataSpace.OSpace)
            {
                throw new ArgumentException(
                    String.Format(CultureInfo.CurrentCulture, Resources.ErrorNonValidDataSpace, dataSpace.ToString()));
            }
            if (dataSpace == DataSpace.CSpace)
            {
                var sgpNamespace = SchemaManager.GetAnnotationNamespaceName();
                if (String.IsNullOrEmpty(sgpNamespace))
                {
                    throw new ArgumentException(
                        String.Format(CultureInfo.CurrentCulture, Resources.ErrorNonValidTargetVersion, targetVersion));
                }
                MetadataProperty sgpMetadataProperty = null;
                if (property.MetadataProperties.TryGetValue(
                    sgpNamespace + ":" + EdmConstants.facetNameStoreGeneratedPattern, false, out sgpMetadataProperty))
                {
                    var sgpValue = sgpMetadataProperty.Value as string;
                    Debug.Assert(
                        false == String.IsNullOrEmpty(sgpValue),
                        "If we found the StoreGeneratedPattern annotation in the CSDL, why weren't we able to find a value?");
                    if (false == String.IsNullOrEmpty(sgpValue))
                    {
                        return (StoreGeneratedPattern)Enum.Parse(typeof(StoreGeneratedPattern), sgpValue, false);
                    }
                }
            }
            else if (dataSpace == DataSpace.SSpace)
            {
                Facet item = null;
                if (property.TypeUsage.Facets.TryGetValue(EdmConstants.facetNameStoreGeneratedPattern, false, out item))
                {
                    return (StoreGeneratedPattern)item.Value;
                }
            }
            return StoreGeneratedPattern.None;
        }
public static StoreGeneratedPattern GetStoreGeneratedPatternValue ( this EdmMember property , Version targetVersion , DataSpace dataSpace ) { if ( targetVersion == null ) { throw new ArgumentNullException ( " " ) ; } if ( dataSpace == DataSpace . CSSpace || dataSpace == DataSpace . OCSpace || dataSpace == DataSpace . OSpace ) { throw new ArgumentException ( String . Format ( CultureInfo . CurrentCulture , Resources . ErrorNonValidDataSpace , dataSpace . ToString ( ) ) ) ; } if ( dataSpace == DataSpace . CSpace ) { var sgpNamespace = SchemaManager . GetAnnotationNamespaceName ( ) ; if ( String . IsNullOrEmpty ( sgpNamespace ) ) { throw new ArgumentException ( String . Format ( CultureInfo . CurrentCulture , Resources . ErrorNonValidTargetVersion , targetVersion ) ) ; } MetadataProperty sgpMetadataProperty = null ; if ( property . MetadataProperties . TryGetValue ( sgpNamespace + " " + EdmConstants . facetNameStoreGeneratedPattern , false , out sgpMetadataProperty ) ) { var sgpValue = sgpMetadataProperty . Value as string ; Debug . Assert ( false == String . IsNullOrEmpty ( sgpValue ) , " " ) ; if ( false == String . IsNullOrEmpty ( sgpValue ) ) { return ( StoreGeneratedPattern ) Enum . Parse ( typeof ( StoreGeneratedPattern ) , sgpValue , false ) ; } } } else if ( dataSpace == DataSpace . SSpace ) { Facet item = null ; if ( property . TypeUsage . Facets . TryGetValue ( EdmConstants . facetNameStoreGeneratedPattern , false , out item ) ) { return ( StoreGeneratedPattern ) item . Value ; } } return StoreGeneratedPattern . None ; }
Obtains the StoreGeneratedPattern value of an EdmProperty, given a target version and DataSpace
Obtains the StoreGeneratedPattern value of an EdmProperty given a target version and DataSpace
// In the CSDL, StoreGeneratedPattern exists as an annotation in the EntityStoreSchemaGeneratorNamespace // In the SSDL, StoreGeneratedPattern exists as a facet
One of the StoreGeneratedPattern values, or String.Empty if the attribute or value does not exist
One of the StoreGeneratedPattern values or String . Empty if the attribute or value does not exist
EdmMember
this
targetVersion
Version
Used to correctly look up the StoreGeneratedPattern value in the EdmProperty
Used to correctly look up the StoreGeneratedPattern value in the EdmProperty
dataSpace
DataSpace
DataSpace where the EdmProperty lives (either CSDL or SSDL)
DataSpace where the EdmProperty lives ( either CSDL or SSDL )
property
None