コード例 #1
0
            /// <summary>
            /// Attempts to get the primitive store type for the given type name. This method takes the target .NET Framework
            /// into account and only returns primitive types that are supported by the Framework that is being targeted.
            /// If a type is recognized but excluded because it is not supported by the target Framework then the excludedForTarget
            /// flag is set to true.
            /// </summary>
            internal bool TryGetStorePrimitiveType(string typeName, out PrimitiveType primitiveType, out bool excludedForTarget)
            {
                excludedForTarget = false;
                var success = ItemCollection.TryGetItem <PrimitiveType>(StoreNamespace + "." + typeName, false, out primitiveType);

                // If targetting 4.0 using 4.5 then we need to ignore geometry and geography types just like we would have done when
                // generating with 4.0. We can only get the base spatial types since we won't reverse engineer to derived spatial
                // types. We don't need to do anything for enums because we will never reverse engineer to an enum.
                if (success &&
                    _targetEntityFrameworkVersion.CompareTo(EntityFrameworkVersions.Version3) < 0 &&
                    (primitiveType.PrimitiveTypeKind == PrimitiveTypeKind.Geography || primitiveType.PrimitiveTypeKind == PrimitiveTypeKind.Geometry))
                {
                    excludedForTarget = true;
                    primitiveType     = null;
                    return(false);
                }
                return(success);
            }