コード例 #1
0
        private static bool ReadyForFurtherValidation(ReferentialConstraintRoleElement role)
        {
            if (role == null)
            {
                return(false);
            }

            if (role.End == null)
            {
                return(false);
            }

            if (role.RoleProperties.Count == 0)
            {
                return(false);
            }

            foreach (PropertyRefElement propRef in role.RoleProperties)
            {
                if (propRef.Property == null)
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #2
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 (int 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)
                {
                    bool foundKeyProperty = false;

                    // All properties that are defined in ToProperties must be the key property on the entity type
                    for (int 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;
            }
        }
コード例 #3
0
 internal void HandleReferentialConstraintDependentRoleElement(XmlReader reader)
 {
     _dependentRole = new ReferentialConstraintRoleElement(this);
     _dependentRole.Parse(reader);
 }
コード例 #4
0
 internal void HandleReferentialConstraintPrincipalRoleElement(XmlReader reader)
 {
     _principalRole = new ReferentialConstraintRoleElement(this);
     _principalRole.Parse(reader);
 }
コード例 #5
0
 internal void HandleReferentialConstraintDependentRoleElement(XmlReader reader)
 {
     _dependentRole = new ReferentialConstraintRoleElement(this);
     _dependentRole.Parse(reader);
 }
コード例 #6
0
 internal void HandleReferentialConstraintPrincipalRoleElement(XmlReader reader)
 {
     _principalRole = new ReferentialConstraintRoleElement(this);
     _principalRole.Parse(reader);
 }
コード例 #7
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;
            }
        }
コード例 #8
0
        private static bool ReadyForFurtherValidation(ReferentialConstraintRoleElement role)
        {
            if (role == null)
            {
                return false;
            }

            if (role.End == null)
            {
                return false;
            }

            if (role.RoleProperties.Count == 0)
            {
                return false;
            }

            foreach (var propRef in role.RoleProperties)
            {
                if (propRef.Property == null)
                {
                    return false;
                }
            }

            return true;
        }