Esempio n. 1
0
        protected virtual string GetStatementSql(InsertStatement statement)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("INSERT INTO ");
            sb.Append(GetSql(statement.Identifier));

            if (statement.Columns.Count > 0)
            {
                sb.Append(Environment.NewLine);
                sb.Append(" (");
                int columnCount = statement.Columns.Count;
                for (int i = 0; i < columnCount; i++)
                {
                    sb.Append(GetSql(statement.Columns[i]));
                    sb.Append(i == (columnCount - 1) ? ", " : "");
                }
                sb.Append(")");
            }

            sb.Append(Environment.NewLine);
            sb.Append(" VALUES ");

            int rowCount = statement.Values.Count;

            for (int j = 0; j < rowCount; j++)
            {
                sb.Append("(");
                List <IExpression> expr = statement.Values[j];

                int columnCount = expr.Count;
                for (int i = 0; i < columnCount; i++)
                {
                    sb.Append(GetSql(expr[i]));
                    sb.Append(i == (columnCount - 1) ? ", " : "");
                }

                sb.Append(")");
                sb.Append(j == (rowCount - 1) ? "," + Environment.NewLine : "");
            }

            sb.Append(';');
            return(sb.ToString());
        }
Esempio n. 2
0
		protected virtual string GetStatementSql (InsertStatement statement)
		{
			StringBuilder sb = new StringBuilder ();
			
			sb.Append ("INSERT INTO ");
			sb.Append (GetSql (statement.Identifier));

			if (statement.Columns.Count > 0) {
				sb.Append (Environment.NewLine);
				sb.Append (" (");
				int columnCount = statement.Columns.Count;
				for (int i=0; i<columnCount; i++) {
					sb.Append (GetSql (statement.Columns[i]));
					sb.Append (i == (columnCount - 1) ? ", " : "");
				}
				sb.Append (")");
			}
			
			sb.Append (Environment.NewLine);
			sb.Append (" VALUES ");
			
			int rowCount = statement.Values.Count;
			for (int j=0; j<rowCount; j++) {
				sb.Append ("(");
				List<IExpression> expr = statement.Values[j];
				
				int columnCount = expr.Count;
				for (int i=0; i<columnCount; i++) {
					sb.Append (GetSql (expr[i]));
					sb.Append (i == (columnCount - 1) ? ", " : "");
				}

				sb.Append (")");
				sb.Append (j == (rowCount - 1) ? "," + Environment.NewLine : "");
			}

			sb.Append (';');
			return sb.ToString ();
		}