/// <summary>Visit an unbound constrain.</summary> /// <param name="unboundConstrain">Unbound constrain to be visited.</param> protected override void VisitUnboundConstrain(UnboundConstrain unboundConstrain) { VisitComponent(unboundConstrain.Subject); _commandText.Append(" "); VisitComponent(unboundConstrain.Predicate); _commandText.Append(" "); VisitComponent(unboundConstrain.Value); _commandText.Append(" . "); }
/// <summary>Visits a select clause.</summary> /// <param name="selectClause">Select clause to be visited.</param> /// <param name="queryModel">Query model containing given select clause.</param> public override void VisitSelectClause(SelectClause selectClause, Remotion.Linq.QueryModel queryModel) { QuerySourceReferenceExpression querySource = FindQuerySource(selectClause.Selector); _visitor.VisitExpression(selectClause.Selector); QueryComponent component = _visitor.RetrieveComponent(); _query = _visitor.Query; _mainFromComponent = _query.FindAllComponents<StrongEntityAccessor>().Where(item => item.SourceExpression == querySource.ReferencedQuerySource).First(); if (_query.Subject == null) { _query.Subject = _mainFromComponent.About; UnboundConstrain genericConstrain = new UnboundConstrain(new Identifier("s"), new Identifier("p"), new Identifier("o"), _mainFromComponent.SourceExpression.FromExpression); _mainFromComponent.Elements.Insert(0, genericConstrain); _query.Select.Add(genericConstrain); } _subject = _query.Subject; queryModel.MainFromClause.Accept(this, queryModel); _query.Select.Add(_mainFromComponent); VisitBodyClauses(queryModel.BodyClauses, queryModel); VisitResultOperators(queryModel.ResultOperators, queryModel); OverrideSelector(component, selectClause.Selector); }
/// <summary>Visit an unbound constrain.</summary> /// <param name="unboundConstrain">Unbound constrain to be visited.</param> protected abstract void VisitUnboundConstrain(UnboundConstrain unboundConstrain);
private void OverrideEntitySelector(Identifier identifier) { UnboundConstrain genericConstrain = new UnboundConstrain(identifier, new Identifier(identifier.Name + "P"), new Identifier(identifier.Name + "O"), _mainFromComponent.SourceExpression.FromExpression); _mainFromComponent.Elements.Add(genericConstrain); _query.Select.Clear(); _query.Select.Add(genericConstrain); UnspecifiedEntityAccessor entityAccessor = new UnspecifiedEntityAccessor(identifier, _mainFromComponent); entityAccessor.Elements.Add(genericConstrain); _query.Select.Add(entityAccessor); int indexOf = -1; if ((indexOf = _query.Elements.IndexOf(_mainFromComponent)) != -1) { _query.Elements.RemoveAt(indexOf); _query.Elements.Insert(indexOf, entityAccessor); } else { _query.Elements.Add(entityAccessor); } if (_mainFromComponent.Elements[0] is UnboundConstrain) { _mainFromComponent.Elements.RemoveAt(0); } }