/// <summary>Constructor with subject and variable naming strategy passed.</summary> /// <param name="variableNamingStrategy">Varialbe naming strategy.</param> /// <param name="variableNamingConvention">Variable naming convention.</param> internal Query(IVariableNamingStrategy variableNamingStrategy, IVariableNamingConvention variableNamingConvention) { _variableNamingStrategy = variableNamingStrategy; _variableNamingConvention = variableNamingConvention; _queryForm = QueryForms.Select; ObservableCollection <IPrefix> prefixes = new ObservableCollection <IPrefix>(); prefixes.CollectionChanged += OnCollectionChanged; _prefixes = prefixes; ObservableCollection <ISelectableQueryComponent> select = new ObservableCollection <ISelectableQueryComponent>(); select.CollectionChanged += OnCollectionChanged; _select = select; ObservableCollection <IQueryElement> elements = new ObservableCollection <IQueryElement>(); elements.CollectionChanged += OnCollectionChanged; _elements = elements; }
private void BeginQuery(bool isSubQuery, QueryForms queryForm, IList <ISelectableQueryComponent> select, Func <string, string> createVariableName, StrongEntityAccessor mainEntityAccessor) { if ((_commandText.Length > 0) && (_commandText[_commandText.Length - 1] != '\n')) { _commandText.AppendLine(); } if (isSubQuery) { Indentation += "\t"; } _commandText.Append(Indentation); _commandText.AppendFormat("{0} ", queryForm.ToString().ToUpper()); if (queryForm == QueryForms.Select) { if (select.Count > 0) { Action <StrongEntityAccessor> temp = _currentStrongEntityAccessorVisitDelegate; foreach (ISelectableQueryComponent expression in select) { ProcessSelectable(isSubQuery, expression, createVariableName, mainEntityAccessor); } _currentStrongEntityAccessorVisitDelegate = temp; } else { _commandText.Append("* "); } } _commandText.AppendLine(); if (queryForm != QueryForms.Ask) { _commandText.Append(Indentation); _commandText.Append("WHERE "); } _commandText.Append("{ "); _commandText.AppendLine(); Indentation += "\t"; }
/// <summary>Constrctor with subject passed.</summary> /// <param name="subject">Subject of this query.</param> internal Query(Identifier subject) : base() { _queryForm = QueryForms.Select; ObservableCollection<Prefix> prefixes = new ObservableCollection<Prefix>(); prefixes.CollectionChanged += OnCollectionChanged; _prefixes = prefixes; ObservableCollection<ISelectableQueryComponent> select = new ObservableCollection<ISelectableQueryComponent>(); select.CollectionChanged += OnCollectionChanged; _select = select; ObservableCollection<QueryElement> elements = new ObservableCollection<QueryElement>(); elements.CollectionChanged += OnCollectionChanged; _elements = elements; _variableNamingStrategy = new UniqueVariableNamingStrategy(this); _variableNamingConvention = new CamelCaseVariableNamingConvention(); if ((_subject = subject) != null) { _subject.OwnerQuery = this; } }
private void BeginQuery(bool isSubQuery, QueryForms queryForm, IList<ISelectableQueryComponent> select, Func<string, string> createVariableName) { _commandText.AppendFormat("{0} ", queryForm.ToString().ToUpper()); if (queryForm == QueryForms.Select) { if (select.Count > 0) { foreach (ISelectableQueryComponent expression in select) { ProcessSelectable(isSubQuery, expression, createVariableName); } } else { _commandText.Append("* "); } } if (queryForm != QueryForms.Ask) { _commandText.Append("WHERE "); } _commandText.Append("{ "); }