Пример #1
0
        /// <summary>
        /// Creates a new <see cref="AliasNode"/> to wrap the results of a subquery with a different alias
        /// </summary>
        /// <param name="select">The subquery to wrap the results of</param>
        /// <param name="identifier">The alias to use for the subquery</param>
        public AliasNode(SelectNode select, Identifier identifier)
        {
            ColumnSet.AddRange(select.ColumnSet);
            Source = select.Source;
            Alias  = identifier.Value;

            // Check for duplicate columns
            var duplicateColumn = select.ColumnSet
                                  .GroupBy(col => col.OutputColumn, StringComparer.OrdinalIgnoreCase)
                                  .Where(g => g.Count() > 1)
                                  .FirstOrDefault();

            if (duplicateColumn != null)
            {
                throw new NotSupportedQueryFragmentException($"The column '{duplicateColumn.Key}' was specified multiple times", identifier);
            }
        }