private Join(SourceCollection sourceCollection, AliasedSource source) { this.sources = sourceCollection; string newSourceName = source.GetSourceName(); if (newSourceName != null) { this.sources.AddSource(newSourceName, source); } }
/// <summary> /// Adds the given SELECT statement to the FROM clause. /// </summary> /// <param name="builder">The SELECT statement to add.</param> /// <param name="alias">The optional alias to give the SELECT statement within the SELECT statement.</param> /// <returns>An object to support aliasing the SELECT statement and defining columns.</returns> public AliasedSource AddSelect(ISelectBuilder builder, string alias = null) { if (builder == null) { throw new ArgumentNullException("builder"); } AliasedSource source = new AliasedSource(builder, alias); sources.AddSource(source.GetSourceName(), source); _from.Add(source); return(source); }
/// <summary> /// Adds the given function to the FROM clause. /// </summary> /// <param name="function">The function to add.</param> /// <param name="alias">The optional alias to give the function within the SELECT statement.</param> /// <returns>An object to support aliasing the function and defining column.</returns> public AliasedSource AddFunction(Function function, string alias = null) { if (function == null) { throw new ArgumentNullException("function"); } AliasedSource source = new AliasedSource(function, alias); sources.AddSource(source.GetSourceName(), source); _from.Add(source); return(source); }
/// <summary> /// Adds the given table to the FROM clause. /// </summary> /// <param name="table">The table to add.</param> /// <param name="alias">The optional alias to give the table within the SELECT statement.</param> /// <returns>An object to support aliasing the table and defining columns.</returns> public AliasedSource AddTable(Table table, string alias = null) { if (table == null) { throw new ArgumentNullException("table"); } AliasedSource source = new AliasedSource(table, alias); sources.AddSource(source.GetSourceName(), source); _from.Add(source); return(source); }
/// <summary> /// Removes the given table or SELECT statement from the FROM clause. /// </summary> /// <param name="source">The table or SELECT statement to remove.</param> /// <returns>True if the table or SELECT statement was found and removed; otherwise, false.</returns> public bool RemoveSource(AliasedSource source) { if (source == null) { throw new ArgumentNullException("joinItem"); } string sourceName = source.GetSourceName(); if (sourceName == null) { return(_from.Remove(source.Source)); } if (sources.Exists(sourceName) && _from.Remove(source)) { sources.Remove(sourceName); return(true); } return(false); }
/// <summary> /// Removes the given table or SELECT statement from the FROM clause. /// </summary> /// <param name="source">The table or SELECT statement to remove.</param> /// <returns>True if the table or SELECT statement was found and removed; otherwise, false.</returns> public bool RemoveSource(AliasedSource source) { if (source == null) { throw new ArgumentNullException("joinItem"); } string sourceName = source.GetSourceName(); if (sourceName == null) { return _from.Remove(source.Source); } if (sources.Exists(sourceName) && _from.Remove(source.Source)) { sources.Remove(sourceName); return true; } return false; }
/// <summary> /// Adds the given table to the FROM clause. /// </summary> /// <param name="table">The table to add.</param> /// <param name="alias">The optional alias to give the table within the SELECT statement.</param> /// <returns>An object to support aliasing the table and defining columns.</returns> public AliasedSource AddTable(Table table, string alias = null) { if (table == null) { throw new ArgumentNullException("table"); } AliasedSource source = new AliasedSource(table, alias); sources.AddSource(source.GetSourceName(), source); _from.Add(source); return source; }
/// <summary> /// Adds the given SELECT statement to the FROM clause. /// </summary> /// <param name="builder">The SELECT statement to add.</param> /// <param name="alias">The optional alias to give the SELECT statement within the SELECT statement.</param> /// <returns>An object to support aliasing the SELECT statement and defining columns.</returns> public AliasedSource AddSelect(ISelectBuilder builder, string alias = null) { if (builder == null) { throw new ArgumentNullException("builder"); } AliasedSource source = new AliasedSource(builder, alias); sources.AddSource(source.GetSourceName(), source); _from.Add(source); return source; }
/// <summary> /// Adds the given function to the FROM clause. /// </summary> /// <param name="function">The function to add.</param> /// <param name="alias">The optional alias to give the function within the SELECT statement.</param> /// <returns>An object to support aliasing the function and defining column.</returns> public AliasedSource AddFunction(Function function, string alias = null) { if (function == null) { throw new ArgumentNullException("function"); } AliasedSource source = new AliasedSource(function, alias); sources.AddSource(source.GetSourceName(), source); _from.Add(source); return source; }