Example #1
0
        public override string ToString()
        {
            var result = CommandText.ToString();

            foreach (var sqlParameter in ParameterCollection)
            {
                if (result.Contains(sqlParameter.ParameterName))
                {
                    switch (sqlParameter.DbType)
                    {
                    case DbType.AnsiString:
                    case DbType.AnsiStringFixedLength:
                    case DbType.Date:
                    case DbType.DateTime:
                    case DbType.DateTime2:
                    case DbType.DateTimeOffset:
                    case DbType.Guid:
                    case DbType.String:
                    case DbType.StringFixedLength:
                    case DbType.Time:
                        result = result.Replace(sqlParameter.ParameterName, $"'{sqlParameter.Value.ToString()}'");
                        break;

                    default:
                        result = result.Replace(sqlParameter.ParameterName, $"{sqlParameter.Value.ToString()}");
                        break;
                    }
                }
            }

            return(result);
        }
Example #2
0
        private SqlCommand GenerateSqlCommand()
        {
            var result = new SqlCommand(CommandText.ToString(), Connection);

            if (Transaction != null)
            {
                result.Transaction = Transaction;
            }

            result.Parameters.AddRange(ParameterCollection.ToArray());

            return(result);
        }
Example #3
0
        public bool EndOfList(string replaceWith)
        {
            bool   flag  = false;
            string input = CommandText.ToString();
            var    match = TrailingCommaRegex.Match(input);

            if (match.Success)
            {
                CommandText.Clear();
                CommandText.Append(input.Remove(input.Length - match.Groups["FullOperator"].Length, match.Groups["FullOperator"].Length));
                CommandText.Append(replaceWith);
                CommandText.Append(match.Groups["LineSuffix"].Value);
                flag = true;
            }
            return(flag);
        }
Example #4
0
        public void QueryNoReader()
        {
            if (_dbConnector != null || Reader != null)
            {
                throw new AegisException(AegisResult.DataReaderNotClosed, "There is already an open DataReader associated with this Connection which must be closed first.");
            }


            _dbConnector         = _pool.GetDBC();
            _command.Connection  = _dbConnector.Connection;
            _command.CommandText = CommandText.ToString();

            Prepare();
            _command.ExecuteNonQuery();
            _dbConnector.QPS.Add(1);
            EndQuery();
        }
Example #5
0
        public bool EndOfWhere(string replaceWith)
        {
            bool   flag  = false;
            string input = CommandText.ToString();
            Match  match = TrailingWhereAndOrRegex.Match(input);

            if (match.Success)
            {
                CommandText.Clear();
                CommandText.Append(input.Remove(input.Length - match.Groups["FullOperator"].Length, match.Groups["FullOperator"].Length));
                if (match.Groups["Operator"].Value.Equals("where", StringComparison.InvariantCultureIgnoreCase))
                {
                    CommandText.Append(match.Groups["LinePrefix"].Value);
                }
                CommandText.Append(replaceWith);
                CommandText.Append(match.Groups["LineSuffix"].Value);
                flag = true;
            }
            return(flag);
        }