Ejemplo n.º 1
0
        internal override void ResolveSecondLevelNames()
        {
            base.ResolveSecondLevelNames();

            if (_unresolvedRelationshipEndRole == null && EntitySet != null)
            {
                // no role provided, infer it
                RelationshipEnd = InferRelationshipEnd(EntitySet);
                if (RelationshipEnd != null)
                {
                    _unresolvedRelationshipEndRole = RelationshipEnd.Name;
                }
            }
            else if (_unresolvedRelationshipEndRole != null)
            {
                IRelationship    relationship = ParentElement.Relationship;
                IRelationshipEnd end;
                if (relationship.TryGetEnd(_unresolvedRelationshipEndRole, out end))
                {
                    RelationshipEnd = end;
                }
                else
                {
                    // couldn't find a matching relationship end for this RelationshipSet end
                    AddError(ErrorCode.InvalidContainerTypeForEnd, EdmSchemaErrorSeverity.Error,
                             System.Data.Entity.Strings.InvalidEntityEndName(Role, relationship.FQName));
                }
            }
        }
Ejemplo n.º 2
0
 internal override void ResolveSecondLevelNames()
 {
     base.ResolveSecondLevelNames();
     if (this._unresolvedRelationshipEndRole == null && this.EntitySet != null)
     {
         this.RelationshipEnd = this.InferRelationshipEnd(this.EntitySet);
         if (this.RelationshipEnd == null)
         {
             return;
         }
         this._unresolvedRelationshipEndRole = this.RelationshipEnd.Name;
     }
     else
     {
         if (this._unresolvedRelationshipEndRole == null)
         {
             return;
         }
         IRelationship    relationship = this.ParentElement.Relationship;
         IRelationshipEnd end;
         if (relationship.TryGetEnd(this._unresolvedRelationshipEndRole, out end))
         {
             this.RelationshipEnd = end;
         }
         else
         {
             this.AddError(ErrorCode.InvalidContainerTypeForEnd, EdmSchemaErrorSeverity.Error, (object)Strings.InvalidEntityEndName((object)this.Role, (object)relationship.FQName));
         }
     }
 }
Ejemplo n.º 3
0
        internal override void ResolveTopLevelNames()
        {
            base.ResolveTopLevelNames();

            SchemaType element;

            if (!Schema.ResolveTypeName(this, _unresolvedRelationshipName, out element))
            {
                return;
            }

            _relationship = element as IRelationship;
            if (_relationship == null)
            {
                AddError(
                    ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error,
                    Strings.BadNavigationPropertyRelationshipNotRelationship(_unresolvedRelationshipName));
                return;
            }

            var foundBothEnds = true;

            if (!_relationship.TryGetEnd(_unresolvedFromEndRole, out _fromEnd))
            {
                AddError(
                    ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error,
                    Strings.BadNavigationPropertyUndefinedRole(_unresolvedFromEndRole, _relationship.FQName));
                foundBothEnds = false;
            }

            if (!_relationship.TryGetEnd(_unresolvedToEndRole, out _toEnd))
            {
                AddError(
                    ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error,
                    Strings.BadNavigationPropertyUndefinedRole(_unresolvedToEndRole, _relationship.FQName));

                foundBothEnds = false;
            }

            if (foundBothEnds && _fromEnd == _toEnd)
            {
                AddError(
                    ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error,
                    Strings.BadNavigationPropertyRolesCannotBeTheSame);
            }
        }
Ejemplo n.º 4
0
        internal override void ResolveTopLevelNames()
        {
            IRelationship parentElement = (IRelationship)this.ParentElement.ParentElement;

            if (!parentElement.TryGetEnd(this.Name, out this._end))
            {
                this.AddError(ErrorCode.InvalidRoleInRelationshipConstraint, EdmSchemaErrorSeverity.Error, (object)Strings.InvalidEndRoleInRelationshipConstraint((object)this.Name, (object)parentElement.Name));
            }
            else
            {
                SchemaEntityType type = this._end.Type;
            }
        }
        /// <summary>
        /// Used during the resolve phase to resolve the type name to the object that represents that type
        /// </summary>
        internal override void ResolveTopLevelNames()
        {
            Debug.Assert(!String.IsNullOrEmpty(this.Name), "RoleName should never be empty");
            IRelationship relationship = (IRelationship)this.ParentElement.ParentElement;

            if (!relationship.TryGetEnd(this.Name, out _end))
            {
                AddError(ErrorCode.InvalidRoleInRelationshipConstraint,
                         EdmSchemaErrorSeverity.Error,
                         System.Data.Entity.Strings.InvalidEndRoleInRelationshipConstraint(this.Name, relationship.Name));

                return;
            }

            // we are gauranteed that the _end has gone through ResolveNames, but
            // we are not gauranteed that it was successful
            if (_end.Type == null)
            {
                // an error has already been added for this
                return;
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// </summary>
        internal override void ResolveTopLevelNames()
        {
            base.ResolveTopLevelNames();

            SchemaType element;
            if (!Schema.ResolveTypeName(this, _unresolvedRelationshipName, out element))
            {
                return;
            }

            _relationship = element as IRelationship;
            if (_relationship == null)
            {
                AddError(
                    ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error,
                    Strings.BadNavigationPropertyRelationshipNotRelationship(_unresolvedRelationshipName));
                return;
            }

            var foundBothEnds = true;
            if (!_relationship.TryGetEnd(_unresolvedFromEndRole, out _fromEnd))
            {
                AddError(
                    ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error,
                    Strings.BadNavigationPropertyUndefinedRole(_unresolvedFromEndRole, _relationship.FQName));
                foundBothEnds = false;
            }

            if (!_relationship.TryGetEnd(_unresolvedToEndRole, out _toEnd))
            {
                AddError(
                    ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error,
                    Strings.BadNavigationPropertyUndefinedRole(_unresolvedToEndRole, _relationship.FQName));

                foundBothEnds = false;
            }

            if (foundBothEnds && _fromEnd == _toEnd)
            {
                AddError(
                    ErrorCode.BadNavigationProperty, EdmSchemaErrorSeverity.Error,
                    Strings.BadNavigationPropertyRolesCannotBeTheSame);
            }
        }