AppendSelect() private méthode

private AppendSelect ( string commandText, Clauses clauses, SegmentPositions segmentPositions ) : SqlString
commandText string
clauses Clauses
segmentPositions SegmentPositions
Résultat SqlString
Exemple #1
0
        /// <summary>
        /// Parses the specified command text into a SqlString instance populating the specified <see cref="Clauses"/> if
        /// present in the command text.
        /// </summary>
        /// <param name="commandText">The SQL command text.</param>
        /// <param name="clauses">The clauses to include in the SqlString.</param>
        /// <returns>An SqlString instance populating the specified <see cref="Clauses"/> if present in the command text.</returns>
        public static SqlString Parse(string commandText, Clauses clauses)
        {
            if (string.IsNullOrEmpty(commandText))
            {
                return(new SqlString());
            }

            if (commandText.Contains(Environment.NewLine))
            {
                commandText = commandText.Replace(Environment.NewLine, " ");
            }

            var segmentPositions = SegmentPositions.GetSegmentPositions(commandText);

            var sqlString = new SqlString();

            sqlString.AppendSelect(commandText, clauses, segmentPositions)
            .AppendFrom(commandText, clauses, segmentPositions)
            .AppendWhere(commandText, clauses, segmentPositions)
            .AppendGroupBy(commandText, clauses, segmentPositions)
            .AppendOrderBy(commandText, clauses, segmentPositions);

            return(sqlString);
        }
Exemple #2
0
        /// <summary>
        /// Parses the specified command text into a SqlString instance populating the specified <see cref="Clauses"/> if
        /// present in the command text.
        /// </summary>
        /// <param name="commandText">The SQL command text.</param>
        /// <param name="clauses">The clauses to include in the SqlString.</param>
        /// <returns>An SqlString instance populating the specified <see cref="Clauses"/> if present in the command text.</returns>
        public static SqlString Parse(string commandText, Clauses clauses)
        {
            if (string.IsNullOrEmpty(commandText))
            {
                return new SqlString();
            }

            if (commandText.Contains(Environment.NewLine))
            {
                commandText = commandText.Replace(Environment.NewLine, " ");
            }

            var segmentPositions = SegmentPositions.GetSegmentPositions(commandText);

            var sqlString = new SqlString();

            sqlString.AppendSelect(commandText, clauses, segmentPositions)
                .AppendFrom(commandText, clauses, segmentPositions)
                .AppendWhere(commandText, clauses, segmentPositions)
                .AppendGroupBy(commandText, clauses, segmentPositions)
                .AppendOrderBy(commandText, clauses, segmentPositions);

            return sqlString;
        }