Beispiel #1
0
 private Join(SourceCollection sourceCollection, AliasedSource source)
 {
     this.sources = sourceCollection;
     string newSourceName = source.GetSourceName();
     if (newSourceName != null)
     {
         this.sources.AddSource(newSourceName, source);
     }
 }
 /// <summary>
 /// Initializes a new instance of a SelectBuilder.
 /// </summary>
 public SelectBuilder()
 {
     _from = new List<IJoinItem>();
     _projection = new List<AliasedProjection>();
     _where = new FilterGroup();
     _orderBy = new List<OrderBy>();
     _groupBy = new List<IGroupByItem>();
     _having = new FilterGroup();
     sources = new SourceCollection();
 }
 /// <summary>
 /// Initializes a new instance of a SourceCollection, copying the values
 /// from the given source collection.
 /// </summary>
 /// <param name="other">The source collection to copy the value from.</param>
 internal SourceCollection(SourceCollection other)
 {
     sourceLookup = new Dictionary<string, AliasedSource>(other.sourceLookup, StringComparer.InvariantCultureIgnoreCase);
 }
 /// <summary>
 /// Adds all of the sources from the given collection to the current collection.
 /// </summary>
 /// <param name="other">The other source collection to add item from.</param>
 internal void AddSources(SourceCollection other)
 {
     foreach (KeyValuePair<string, AliasedSource> pair in other.sourceLookup)
     {
         AddSource(pair.Key, pair.Value);
     }
 }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of a SourceCollection, copying the values
 /// from the given source collection.
 /// </summary>
 /// <param name="other">The source collection to copy the value from.</param>
 internal SourceCollection(SourceCollection other)
 {
     sourceLookup = new Dictionary <string, AliasedSource>(other.sourceLookup, StringComparerHelper.DefaultStringComparer);
 }
 private ICommand buildInsertStatement(MatchResult result)
 {
     MatchResult tableResult = result.Matches[SqlGrammar.InsertStatement.Table];
     Table table = buildTable(tableResult);
     IValueProvider valueProvider = null;
     MatchResult valuesResult = result.Matches[SqlGrammar.InsertStatement.Values.Name];
     if (valuesResult.IsMatch)
     {
         ValueList values = new ValueList();
         MatchResult valueListResult = valuesResult.Matches[SqlGrammar.InsertStatement.Values.ValueList];
         if (valueListResult.IsMatch)
         {
             buildValueList(valueListResult, values);
         }
         valueProvider = values;
     }
     MatchResult selectResult = result.Matches[SqlGrammar.InsertStatement.Select.Name];
     if (selectResult.IsMatch)
     {
         MatchResult selectStatementResult = selectResult.Matches[SqlGrammar.InsertStatement.Select.SelectStatement];
         ISelectBuilder selectBuilder = buildSelectStatement(selectStatementResult);
         valueProvider = selectBuilder;
     }
     string alias = null;
     MatchResult aliasExpressionResult = result.Matches[SqlGrammar.InsertStatement.AliasExpression.Name];
     if (aliasExpressionResult.IsMatch)
     {
         MatchResult aliasResult = aliasExpressionResult.Matches[SqlGrammar.InsertStatement.AliasExpression.Alias];
         alias = getToken(aliasResult);
     }
     InsertBuilder builder = new InsertBuilder(table, valueProvider, alias);
     SourceCollection collection = new SourceCollection();
     collection.AddSource(builder.Table.GetSourceName(), builder.Table);
     scope.Push(collection);
     MatchResult columnsResult = result.Matches[SqlGrammar.InsertStatement.Columns.Name];
     if (columnsResult.IsMatch)
     {
         MatchResult columnListResult = columnsResult.Matches[SqlGrammar.InsertStatement.Columns.ColumnList];
         buildColumnsList(columnListResult, builder);
     }
     scope.Pop();
     return builder;
 }
 private ICommand buildDeleteStatement(MatchResult result)
 {
     MatchResult tableResult = result.Matches[SqlGrammar.DeleteStatement.Table];
     Table table = buildTable(tableResult);
     string alias = null;
     MatchResult aliasExpressionResult = result.Matches[SqlGrammar.DeleteStatement.AliasExpression.Name];
     if (aliasExpressionResult.IsMatch)
     {
         MatchResult aliasResult = aliasExpressionResult.Matches[SqlGrammar.DeleteStatement.AliasExpression.Alias];
         alias = getToken(aliasResult);
     }
     DeleteBuilder builder = new DeleteBuilder(table, alias);
     SourceCollection collection = new SourceCollection();
     collection.AddSource(builder.Table.GetSourceName(), builder.Table);
     scope.Push(collection);
     MatchResult whereResult = result.Matches[SqlGrammar.DeleteStatement.Where.Name];
     if (whereResult.IsMatch)
     {
         MatchResult filterListResult = whereResult.Matches[SqlGrammar.DeleteStatement.Where.FilterList];
         IFilter innerFilter = buildOrFilter(filterListResult);
         builder.WhereFilterGroup.AddFilter(innerFilter);
         builder.WhereFilterGroup.Optimize();
     }
     scope.Pop();
     return builder;
 }
 public void Push(SourceCollection collection)
 {
     stack.Add(collection);
 }
 /// <summary>
 /// Initializes a new instance of a SourceCollection, copying the values
 /// from the given source collection.
 /// </summary>
 /// <param name="other">The source collection to copy the value from.</param>
 internal SourceCollection(SourceCollection other)
 {
     sourceLookup = new Dictionary <string, AliasedSource>(other.sourceLookup, StringComparer.InvariantCultureIgnoreCase);
 }