コード例 #1
0
        public virtual ISQLBuilder Emit(string statement, params object[] formatArgs)
        {
            if (formatArgs.Length > 0)
            {
                var formatArgs2 = formatArgs.Select(o => {
                    if (o is ISQLBuilder)
                    {
                        return(((ISQLBuilder)o).ToString());
                    }

                    if (o is SQLBuilderCommand)
                    {
                        var command = o as SQLBuilderCommand;
                        var builder = LeafBuilder.CreateBuilder();
                        command.Execute(builder);
                        return(builder.ToString());

                        /*var command = o as SQLBuilderCommand;
                         *      var stringBuilder = _currentStatement.Item2;
                         *      var currentLength = stringBuilder.Length;
                         *      command.TargetBuilder = command.TargetBuilder ?? this;		// decorator's set the target to themselves if they need to
                         *      command.Execute();
                         *      return (object)stringBuilder.ChopFromEnd(stringBuilder.Length - currentLength);*/
                    }
                    return(o);
                });
                CurrentStatement.Item2.AppendFormat(statement, formatArgs2.ToArray());
            }
            else
            {
                CurrentStatement.Item2.Append(statement);
            }
            return(this);
        }
コード例 #2
0
        public static string QuickString(this ISQLBuilder sqlBuilder, string sql, params object[] args)
        {
            var newBuilder = sqlBuilder.CreateBuilder();

            return(newBuilder.Emit(sql, args).ToString());
        }
コード例 #3
0
 public virtual ISQLBuilder CreateBuilder()
 {
     return(_internalBuilder.CreateBuilder());
 }