private IEnumerable <string> ComputePrincipalKeyPropertiesNotFoundInPrincipalProperties()
        {
            List <string> strs = null;
            IEnumerator <IEdmStructuralProperty> enumerator = this.PrincipalEnd.EntityType.Key().GetEnumerator();

            using (enumerator)
            {
                Func <CsdlPropertyReference, bool> func = null;
                while (enumerator.MoveNext())
                {
                    IEdmStructuralProperty              current    = enumerator.Current;
                    CsdlReferentialConstraintRole       principal  = this.constraint.Principal;
                    IEnumerable <CsdlPropertyReference> properties = principal.Properties;
                    if (func == null)
                    {
                        func = (CsdlPropertyReference reference) => reference.PropertyName == current.Name;
                    }
                    CsdlPropertyReference csdlPropertyReference = properties.Where <CsdlPropertyReference>(func).FirstOrDefault <CsdlPropertyReference>();
                    if (csdlPropertyReference != null)
                    {
                        continue;
                    }
                    strs = CsdlSemanticsElement.AllocateAndAdd <string>(strs, current.Name);
                }
            }
            List <string>        strs1 = strs;
            IEnumerable <string> strs2 = strs1;

            if (strs1 == null)
            {
                strs2 = Enumerable.Empty <string>();
            }
            return(strs2);
        }
        private IEnumerable <EdmError> ComputeErrors()
        {
            List <EdmError> edmErrors = null;

            if (this.EntityType as UnresolvedEntityType != null)
            {
                edmErrors = CsdlSemanticsElement.AllocateAndAdd <EdmError>(edmErrors, this.EntityType.Errors());
            }
            List <EdmError>        edmErrors1 = edmErrors;
            IEnumerable <EdmError> edmErrors2 = edmErrors1;

            if (edmErrors1 == null)
            {
                edmErrors2 = Enumerable.Empty <EdmError>();
            }
            return(edmErrors2);
        }
        private IEnumerable <EdmError> ComputeErrors()
        {
            List <EdmError> edmErrors  = null;
            IEdmEntityType  entityType = this.PrincipalEnd.EntityType;
            CsdlReferentialConstraintRole principal = this.constraint.Principal;
            CsdlReferentialConstraintRole dependent = this.constraint.Dependent;

            if (this.constraint.Principal.Role == this.constraint.Dependent.Role)
            {
                edmErrors = CsdlSemanticsElement.AllocateAndAdd <EdmError>(edmErrors, new EdmError(base.Location, EdmErrorCode.SameRoleReferredInReferentialConstraint, Strings.EdmModel_Validator_Semantic_SameRoleReferredInReferentialConstraint(this.constraint.Principal.Role)));
            }
            if (this.constraint.Dependent.Role != this.context.End1.Name && this.constraint.Dependent.Role != this.context.End2.Name)
            {
                edmErrors = CsdlSemanticsElement.AllocateAndAdd <EdmError>(edmErrors, new EdmError(base.Location, EdmErrorCode.InvalidRoleInRelationshipConstraint, Strings.CsdlParser_InvalidEndRoleInRelationshipConstraint(this.constraint.Dependent.Role, this.context.Name)));
            }
            if (this.constraint.Principal.Role != this.context.End1.Name && this.constraint.Principal.Role != this.context.End2.Name)
            {
                edmErrors = CsdlSemanticsElement.AllocateAndAdd <EdmError>(edmErrors, new EdmError(base.Location, EdmErrorCode.InvalidRoleInRelationshipConstraint, Strings.CsdlParser_InvalidEndRoleInRelationshipConstraint(this.constraint.Principal.Role, this.context.Name)));
            }
            if (edmErrors == null)
            {
                if (principal.Properties.Count <CsdlPropertyReference>() != dependent.Properties.Count <CsdlPropertyReference>())
                {
                    edmErrors = CsdlSemanticsElement.AllocateAndAdd <EdmError>(edmErrors, new EdmError(base.Location, EdmErrorCode.MismatchNumberOfPropertiesInRelationshipConstraint, Strings.EdmModel_Validator_Semantic_MismatchNumberOfPropertiesinRelationshipConstraint));
                }
                if (entityType.Key().Count <IEdmStructuralProperty>() != principal.Properties.Count <CsdlPropertyReference>() || this.PrincipalKeyPropertiesNotFoundInPrincipalProperties.Count <string>() != 0)
                {
                    string str = Strings.EdmModel_Validator_Semantic_InvalidPropertyInRelationshipConstraintPrimaryEnd(string.Concat(this.DependentEnd.DeclaringAssociation.Namespace, (char)46, this.DependentEnd.DeclaringAssociation.Name), this.constraint.Principal.Role);
                    edmErrors = CsdlSemanticsElement.AllocateAndAdd <EdmError>(edmErrors, new EdmError(base.Location, EdmErrorCode.BadPrincipalPropertiesInReferentialConstraint, str));
                }
                foreach (string dependentPropertiesNotFoundInDependentType in this.DependentPropertiesNotFoundInDependentType)
                {
                    string str1 = Strings.EdmModel_Validator_Semantic_InvalidPropertyInRelationshipConstraintDependentEnd(dependentPropertiesNotFoundInDependentType, this.constraint.Dependent.Role);
                    edmErrors = CsdlSemanticsElement.AllocateAndAdd <EdmError>(edmErrors, new EdmError(base.Location, EdmErrorCode.InvalidPropertyInRelationshipConstraint, str1));
                }
            }
            List <EdmError>        edmErrors1 = edmErrors;
            IEnumerable <EdmError> edmErrors2 = edmErrors1;

            if (edmErrors1 == null)
            {
                edmErrors2 = Enumerable.Empty <EdmError>();
            }
            return(edmErrors2);
        }
Exemple #4
0
        private IEnumerable <EdmError> ComputeErrors()
        {
            List <EdmError> edmErrors = null;

            if (this.Association as UnresolvedAssociation != null)
            {
                edmErrors = CsdlSemanticsElement.AllocateAndAdd <EdmError>(edmErrors, this.Association.Errors());
            }
            if (this.End1.Role != null && this.End2.Role != null && this.End1.Role.Name == this.End2.Role.Name)
            {
                edmErrors = CsdlSemanticsElement.AllocateAndAdd <EdmError>(edmErrors, new EdmError(this.End2.Location(), EdmErrorCode.InvalidName, Strings.EdmModel_Validator_Semantic_DuplicateEndName(this.End1.Role.Name)));
            }
            List <EdmError>        edmErrors1 = edmErrors;
            IEnumerable <EdmError> edmErrors2 = edmErrors1;

            if (edmErrors1 == null)
            {
                edmErrors2 = Enumerable.Empty <EdmError>();
            }
            return(edmErrors2);
        }
        private IEnumerable <string> ComputeDependentPropertiesNotFoundInDependentType()
        {
            List <string>  strs       = new List <string>();
            IEdmEntityType entityType = this.DependentEnd.EntityType;

            foreach (CsdlPropertyReference property in this.constraint.Dependent.Properties)
            {
                if (entityType.FindProperty(property.PropertyName) != null)
                {
                    continue;
                }
                strs = CsdlSemanticsElement.AllocateAndAdd <string>(strs, property.PropertyName);
            }
            List <string>        strs1 = strs;
            IEnumerable <string> strs2 = strs1;

            if (strs1 == null)
            {
                strs2 = Enumerable.Empty <string>();
            }
            return(strs2);
        }
        private IEnumerable <EdmError> ComputeErrors()
        {
            List <EdmError> edmErrors = null;

            if (this.association.End1.Name == this.association.End2.Name)
            {
                List <EdmError> edmErrors1  = edmErrors;
                EdmLocation     location    = this.association.End2.Location;
                EdmLocation     edmLocation = location;
                if (location == null)
                {
                    edmLocation = base.Location;
                }
                edmErrors = CsdlSemanticsElement.AllocateAndAdd <EdmError>(edmErrors1, new EdmError(edmLocation, EdmErrorCode.AlreadyDefined, Strings.EdmModel_Validator_Semantic_EndNameAlreadyDefinedDuplicate(this.association.End1.Name)));
            }
            List <EdmError>        edmErrors2 = edmErrors;
            IEnumerable <EdmError> edmErrors3 = edmErrors2;

            if (edmErrors2 == null)
            {
                edmErrors3 = Enumerable.Empty <EdmError>();
            }
            return(edmErrors3);
        }