Esempio n. 1
0
        /// <summary>
        ///     Handler for the EntityType element
        /// </summary>
        /// <param name="reader"> xml reader currently positioned at EntityType element </param>
        private void HandleEntityTypeElement(XmlReader reader)
        {
            DebugCheck.NotNull(reader);

            var itemType = new SchemaEntityType(this);

            itemType.Parse(reader);

            TryAddType(itemType, true /*doNotAddErrorForEmptyName*/);
        }
Esempio n. 2
0
        /// <summary>
        ///     Since this method can be used in different context, this method does not add any errors
        ///     Please make sure that the caller of this methods handles the error case and add errors
        ///     appropriately
        /// </summary>
        /// <param name="entityType"> </param>
        /// <returns> </returns>
        internal bool ResolveNames(SchemaEntityType entityType)
        {
            if (string.IsNullOrEmpty(Name))
            {
                // Don't flag this error. This must already must have flaged as error, while handling name attribute
                return true;
            }

            // Make sure there is a property by this name
            _property = entityType.FindProperty(Name);

            return (_property != null);
        }
Esempio n. 3
0
        private static bool TypeDefinesNewConcurrencyProperties(SchemaEntityType itemType)
        {
            foreach (var property in itemType.Properties)
            {
                if (property.Type is ScalarType &&
                    MetadataHelper.GetConcurrencyMode(property.TypeUsage) != ConcurrencyMode.None)
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 4
0
        /// <summary>
        ///     Since this method can be used in different context, this method does not add any errors
        ///     Please make sure that the caller of this methods handles the error case and add errors
        ///     appropriately
        /// </summary>
        /// <param name="entityType"> </param>
        /// <returns> </returns>
        internal bool ResolveNames(SchemaEntityType entityType)
        {
            if (string.IsNullOrEmpty(Name))
            {
                // Don't flag this error. This must already must have flaged as error, while handling name attribute
                return(true);
            }

            // Make sure there is a property by this name
            _property = entityType.FindProperty(Name);

            return(_property != null);
        }
Esempio n. 5
0
        /// <summary>
        ///     Resolves the given property names to the property in the item
        ///     Also checks whether the properties form the key for the given type and whether all the properties are nullable or not
        /// </summary>
        /// <param name="roleElement"> </param>
        /// <param name="itemType"> </param>
        /// <param name="isKeyProperty"> </param>
        /// <param name="areAllPropertiesNullable"> </param>
        /// <param name="isSubsetOfKeyProperties"> </param>
        private static void IsKeyProperty(
            ReferentialConstraintRoleElement roleElement, SchemaEntityType itemType,
            out bool isKeyProperty,
            out bool areAllPropertiesNullable,
            out bool isAnyPropertyNullable,
            out bool isSubsetOfKeyProperties)
        {
            isKeyProperty            = true;
            areAllPropertiesNullable = true;
            isAnyPropertyNullable    = false;
            isSubsetOfKeyProperties  = true;

            if (itemType.KeyProperties.Count
                != roleElement.RoleProperties.Count)
            {
                isKeyProperty = false;
            }

            // Checking that ToProperties must be the key properties in the entity type referred by the ToRole
            for (var i = 0; i < roleElement.RoleProperties.Count; i++)
            {
                // Once we find that the properties in the constraint are not a subset of the
                // Key, one need not search for it every time
                if (isSubsetOfKeyProperties)
                {
                    var foundKeyProperty = false;

                    // All properties that are defined in ToProperties must be the key property on the entity type
                    for (var j = 0; j < itemType.KeyProperties.Count; j++)
                    {
                        if (itemType.KeyProperties[j].Property
                            == roleElement.RoleProperties[i].Property)
                        {
                            foundKeyProperty = true;
                            break;
                        }
                    }

                    if (!foundKeyProperty)
                    {
                        isKeyProperty           = false;
                        isSubsetOfKeyProperties = false;
                    }
                }

                areAllPropertiesNullable &= roleElement.RoleProperties[i].Property.Nullable;
                isAnyPropertyNullable    |= roleElement.RoleProperties[i].Property.Nullable;
            }
        }
        /// <summary>
        ///     Used during the resolve phase to resolve the type name to the object that represents that type
        /// </summary>
        internal override void ResolveTopLevelNames()
        {
            base.ResolveTopLevelNames();

            if (_entityType == null)
            {
                SchemaType type = null;
                if (! Schema.ResolveTypeName(this, _unresolvedEntityTypeName, out type))
                {
                    return;
                }

                _entityType = type as SchemaEntityType;
                if (_entityType == null)
                {
                    AddError(
                        ErrorCode.InvalidPropertyType, EdmSchemaErrorSeverity.Error,
                        Strings.InvalidEntitySetType(_unresolvedEntityTypeName));
                    return;
                }
            }
        }
Esempio n. 7
0
        private static bool TypeIsSubTypeOf(
            SchemaEntityType itemType, Dictionary <SchemaEntityType, EntityContainerEntitySet> baseEntitySetTypes,
            out EntityContainerEntitySet set)
        {
            if (itemType.IsTypeHierarchyRoot)
            {
                // can't be a sub type if we are a base type
                set = null;
                return(false);
            }

            // walk up the hierarchy looking for a base that is the base type of an entityset
            for (var baseType = itemType.BaseType as SchemaEntityType; baseType != null; baseType = baseType.BaseType as SchemaEntityType)
            {
                if (baseEntitySetTypes.ContainsKey(baseType))
                {
                    set = baseEntitySetTypes[baseType];
                    return(true);
                }
            }

            set = null;
            return(false);
        }
 /// <summary>
 /// </summary>
 /// <param name="parent"> </param>
 public NavigationProperty(SchemaEntityType parent)
     : base(parent)
 {
 }
Esempio n. 9
0
        private static bool TypeDefinesNewConcurrencyProperties(SchemaEntityType itemType)
        {
            foreach (var property in itemType.Properties)
            {
                if (property.Type is ScalarType
                    && MetadataHelper.GetConcurrencyMode(property.TypeUsage) != ConcurrencyMode.None)
                {
                    return true;
                }
            }

            return false;
        }
Esempio n. 10
0
        private static bool TypeIsSubTypeOf(
            SchemaEntityType itemType, Dictionary<SchemaEntityType, EntityContainerEntitySet> baseEntitySetTypes,
            out EntityContainerEntitySet set)
        {
            if (itemType.IsTypeHierarchyRoot)
            {
                // can't be a sub type if we are a base type
                set = null;
                return false;
            }

            // walk up the hierarchy looking for a base that is the base type of an entityset
            for (var baseType = itemType.BaseType as SchemaEntityType; baseType != null; baseType = baseType.BaseType as SchemaEntityType)
            {
                if (baseEntitySetTypes.ContainsKey(baseType))
                {
                    set = baseEntitySetTypes[baseType];
                    return true;
                }
            }

            set = null;
            return false;
        }
        /// <summary>
        ///     Resolves the given property names to the property in the item
        ///     Also checks whether the properties form the key for the given type and whether all the properties are nullable or not
        /// </summary>
        /// <param name="roleElement"> </param>
        /// <param name="itemType"> </param>
        /// <param name="isKeyProperty"> </param>
        /// <param name="areAllPropertiesNullable"> </param>
        /// <param name="isSubsetOfKeyProperties"> </param>
        private static void IsKeyProperty(
            ReferentialConstraintRoleElement roleElement, SchemaEntityType itemType,
            out bool isKeyProperty,
            out bool areAllPropertiesNullable,
            out bool isAnyPropertyNullable,
            out bool isSubsetOfKeyProperties)
        {
            isKeyProperty = true;
            areAllPropertiesNullable = true;
            isAnyPropertyNullable = false;
            isSubsetOfKeyProperties = true;

            if (itemType.KeyProperties.Count
                != roleElement.RoleProperties.Count)
            {
                isKeyProperty = false;
            }

            // Checking that ToProperties must be the key properties in the entity type referred by the ToRole
            for (var i = 0; i < roleElement.RoleProperties.Count; i++)
            {
                // Once we find that the properties in the constraint are not a subset of the
                // Key, one need not search for it every time
                if (isSubsetOfKeyProperties)
                {
                    var foundKeyProperty = false;

                    // All properties that are defined in ToProperties must be the key property on the entity type
                    for (var j = 0; j < itemType.KeyProperties.Count; j++)
                    {
                        if (itemType.KeyProperties[j].Property
                            == roleElement.RoleProperties[i].Property)
                        {
                            foundKeyProperty = true;
                            break;
                        }
                    }

                    if (!foundKeyProperty)
                    {
                        isKeyProperty = false;
                        isSubsetOfKeyProperties = false;
                    }
                }

                areAllPropertiesNullable &= roleElement.RoleProperties[i].Property.Nullable;
                isAnyPropertyNullable |= roleElement.RoleProperties[i].Property.Nullable;
            }
        }
 /// <summary>
 /// Constructs an EntityContainerAssociationSetEnd
 /// </summary>
 /// <param name="parentElement">Reference to the schema element.</param>
 public EntityKeyElement(SchemaEntityType parentElement)
     : base(parentElement)
 {
 }
        /// <summary>
        ///     Used during the resolve phase to resolve the type name to the object that represents that type
        /// </summary>
        internal override void ResolveTopLevelNames()
        {
            base.ResolveTopLevelNames();

            if (_entityType == null)
            {
                SchemaType type = null;
                if (! Schema.ResolveTypeName(this, _unresolvedEntityTypeName, out type))
                {
                    return;
                }

                _entityType = type as SchemaEntityType;
                if (_entityType == null)
                {
                    AddError(
                        ErrorCode.InvalidPropertyType, EdmSchemaErrorSeverity.Error,
                        Strings.InvalidEntitySetType(_unresolvedEntityTypeName));
                    return;
                }
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Handler for the EntityType element
        /// </summary>
        /// <param name="reader">xml reader currently positioned at EntityType element</param>
        private void HandleEntityTypeElement(XmlReader reader)
        {
            Debug.Assert(reader != null);

            var itemType = new SchemaEntityType(this);

            itemType.Parse(reader);

            TryAddType(itemType, true /*doNotAddErrorForEmptyName*/);
        }
Esempio n. 15
0
 /// <summary>
 /// </summary>
 /// <param name="parent"> </param>
 public NavigationProperty(SchemaEntityType parent)
     : base(parent)
 {
 }
Esempio n. 16
0
 /// <summary>
 ///     Constructs an EntityContainerAssociationSetEnd
 /// </summary>
 /// <param name="parentElement"> Reference to the schema element. </param>
 public EntityKeyElement(SchemaEntityType parentElement)
     : base(parentElement)
 {
 }