コード例 #1
0
 /// <summary>Visit an optional patterns.</summary>
 /// <param name="optionalPattern">Optional patterns to be visited.</param>
 protected abstract void VisitOptionalPattern(OptionalPattern optionalPattern);
コード例 #2
0
        /// <summary>Visit an optional patterns.</summary>
        /// <param name="optionalPattern">Optional patterns accessor to be visited.</param>
        protected override void VisitOptionalPattern(OptionalPattern optionalPattern)
        {
            _commandText.Append("OPTIONAL { ");
            foreach (EntityConstrain pattern in optionalPattern.Patterns)
            {
                VisitComponent(pattern);
            }

            _commandText.Append(" } ");
        }
コード例 #3
0
        private void VisitAnyResultOperator(AnyResultOperator anyResultOperator, Remotion.Linq.QueryModel queryModel, int index)
        {
            string targetIdentifierString = _visitor.Query.CreateIdentifier(_visitor.ItemNameOverride);
            IList<EntityConstrain> entityConstrains = null;
            StrongEntityAccessor entityAccessor = (from accessor in _visitor.Query.GetQueryComponentNavigator().FindAllComponents<StrongEntityAccessor>()
                                                   let constrains = accessor.Elements.OfType<EntityConstrain>()
                                                   from constrain in constrains
                                                   let predicate = constrain.Predicate as Literal
                                                   where predicate != null
                                                   let predicateUri = (Uri)predicate.Value
                                                   let identifier = constrain.Value as Identifier
                                                   where identifier != null
                                                   let identifierString = _visitor.Query.RetrieveIdentifier(identifier.Name)
                                                   where identifierString == targetIdentifierString
                                                   where (entityConstrains = constrains.Where(item =>
                                                       (item.Predicate is Literal) && (((Uri)((Literal)item.Predicate).Value).AbsoluteUri == predicateUri.AbsoluteUri)).ToList()).Count > 0
                                                   select accessor).FirstOrDefault();
            if (entityAccessor != null)
            {
                foreach (EntityConstrain entityConstrain in entityConstrains)
                {
                    int indexOf = entityAccessor.Elements.IndexOf(entityConstrain);
                    entityAccessor.Elements.RemoveAt(indexOf);
                    OptionalPattern optional = new OptionalPattern();
                    optional.Patterns.Add(entityConstrain);
                    entityAccessor.Elements.Insert(indexOf, optional);
                }
            }

            Call call = new Call(MethodNames.Bound);
            _result = call;
        }