private DbRelatedEntityRef VisitRelatedEntityRef(DbRelatedEntityRef entityRef)
        {
            RelationshipEndMember newSource;
            RelationshipEndMember newTarget;

            VisitRelationshipEnds(entityRef.SourceEnd, entityRef.TargetEnd, out newSource, out newTarget);
            DbExpression newTargetRef = this.VisitExpression(entityRef.TargetEntityReference);

            if (!object.ReferenceEquals(entityRef.SourceEnd, newSource) ||
                !object.ReferenceEquals(entityRef.TargetEnd, newTarget) ||
                !object.ReferenceEquals(entityRef.TargetEntityReference, newTargetRef))
            {
                return(CqtBuilder.CreateRelatedEntityRef(newSource, newTarget, newTargetRef));
            }
            else
            {
                return(entityRef);
            }
        }
 internal virtual void VisitRelatedEntityReference(DbRelatedEntityRef relatedEntityRef)
 {
     VisitExpression(relatedEntityRef.TargetEntityReference);
 }