public override void GenerateSql(ISqlDumper dmp, DbTypeBase targetType) { FunctionName.GenerateSql(dmp); dmp.Put("%:s", LeftBracket, "("); Arguments.GenerateSql(dmp); dmp.Put("%:s", RightBracket, ")"); }
public override void GenerateSql(ISqlDumper dmp) { base.GenerateSql(dmp); dmp.Put("&3>&3n"); Source.GenerateSql(dmp); dmp.Put("&3<"); }
public override void GenSql(ISqlDumper dmp) { dmp.Put("^delete "); if (TopRecords != null) { dmp.Put("^top(%s) ", TopRecords); } if (dmp.Factory.DialectCaps.AllowDeleteFrom) { if (DeleteTarget != null) { DeleteTarget.GenSqlRef(dmp); } GenerateFrom(dmp); } else { dmp.Put("^from "); if (DeleteTarget != null) { DeleteTarget.GenSqlRef(dmp); } } if (Where != null) { Where.GenSql(dmp); } }
private void ProcessTree(ITree tree) { int type = tree.Type; if (type == m_tokens.F_DEC) { m_dmp.Put("&<"); } if (type == m_tokens.F_INC) { m_dmp.Put("&>"); } if (type == m_tokens.F_NL) { m_dmp.Put("&n"); } if (tree.Line > 0 && tree.Text != null) { if (tree.Line > m_lastDumpLine || tree.CharPositionInLine > m_nextDumpCharPos) { m_dmp.Put("&s"); } m_dmp.Put("%s", tree.Text); m_lastDumpLine = tree.Line; m_nextDumpCharPos = tree.CharPositionInLine + tree.Text.Length; } for (int i = 0; i < tree.ChildCount; i++) { var child = tree.GetChild(i); ProcessTree(child); } }
protected void GenerateFrom(ISqlDumper dmp) { if (From.All(x => x.Source == null)) { return; } dmp.Put("&n^from &>"); bool wasfromItem = false; foreach (var fromItem in From) { //if (fromItem.Source == null) throw new Exception("DBSH-00000 Source of FROM is NULL"); if (fromItem.Source == null) { continue; } if (wasfromItem) { dmp.Put(",&n"); } fromItem.GenSql(dmp); wasfromItem = true; } dmp.Put("&<"); }
public override void RenderSql(ConditionExpressionDesigner leftExpr, ISqlDumper dmp) { dmp.Put(" %k ", Sql); Expr1.RenderSql(dmp); dmp.Put(" ^and "); Expr1.RenderSql(dmp); }
public override void GenerateSql(ISqlDumper dmp) { dmp.Put("&s%:k", WhenPos, "when"); WhenExpr.GenerateSql(dmp); dmp.Put("&s%:k", ThenPos, "then"); ThenExpr.GenerateSql(dmp); }
protected void DumpWhere(ITableStructure tbl, ISqlDumper dmp) { if (!GenerateWhere) { return; } dmp.Put("^where&>&n"); bool was = false; foreach (var col in tbl.Columns) { if (was) { dmp.Put("&n^and "); } if (UseWhereParameters) { dmp.Put("%i = '###%s###'", col.ColumnName, col.ColumnName); } else { dmp.Put("%i ^is ^null", col.ColumnName); } was = true; } dmp.Put("&<&n"); }
public override void GenSql(ISqlDumper dmp) { if (Conditions.Count == 0) { GenSqlEmpty(dmp); } else { GenSqlBegin(dmp); bool was = false; bool isIndent = false; foreach (var item in Conditions) { if (was) { if (!isIndent) { dmp.Put("&>"); isIndent = true; } dmp.Put("&n"); GenSqlConjuction(dmp); } GenSqlItem(item, dmp); was = true; } GenSqlEnd(dmp); if (isIndent) { dmp.Put("&<"); } } }
public override void GenerateSql(ISqlDumper dmp, DbTypeBase targetType) { Value.GenerateSql(dmp); dmp.Put("&s%:k", BetweenPos, "between"); LowerBound.GenerateSql(dmp); dmp.Put("&s%:k", AndPos, "and"); UpperBound.GenerateSql(dmp); }
public void GenerateSelectAllWhere(ITableStructure tbl, ISqlDumper dmp, ISqlDialect dialect) { dmp.Put("^select &>&n"); DumpColumns(tbl, dmp); dmp.Put("&<&n"); dmp.Put("^from %f&n", tbl.FullName); DumpWhere(tbl, dmp); }
public void WriteDefine(ISqlDumper dmp) { dmp.Put("%f", FullName); if (!Alias.IsEmpty()) { dmp.Put(" %i", Alias); } }
public override void GenSql(ISqlDumper dmp, IDmlfHandler handler) { if (Condition != null) { dmp.Put("&n^where &>"); Condition.GenSql(dmp, handler); dmp.Put("&<"); } }
public override void GenSql(ISqlDumper dmp) { if (Condition != null) { dmp.Put("&n^having &>"); Condition.GenSql(dmp); dmp.Put("&<"); } }
public void RenderSql(ISqlDumper dmp) { if (Root.Children.Count == 0 || !Root.IsEnabled) { return; } dmp.Put("&n^where&>&n"); Root.RenderSql(dmp); dmp.Put("&<"); }
public static void PutEditorInfo(ISqlDumper dmp, string editorInfo) { if (editorInfo == null) return; dmp.Put("&n-- *** EDITOR-INFO-BEGIN ***&n"); foreach (var line in editorInfo.Split('\n')) { dmp.Put("-- %s&n", line.TrimEnd()); } dmp.Put("-- *** EDITOR-INFO-END ***&n"); }
public override void GenerateSql(ISqlDumper dmp) { Source.GenerateSql(dmp); dmp.Put("&3n"); foreach (var j in Joins) { j.GenerateSql(dmp); dmp.Put("&3n"); } }
public override void GenerateSql(ISqlDumper dmp, DbTypeBase targetType) { if (targetType is DbTypeLogical) { dmp.Put("%:s", Original, dmp.Dialect.GetSqlLiteral(m_value != 0)); } else { dmp.Put("&s%:s", Original, m_value.ToString(CultureInfo.InvariantCulture)); } }
public override void GenerateSql(ISqlDumper dmp) { dmp.Put("%:s", LeftBracket, "("); Inner.GenerateSql(dmp); dmp.Put("%:s", RightBracket, ")"); if (Shortcut != null) { dmp.Put("&s"); Shortcut.GenerateSql(dmp); } }
public void GenSqlDef(ISqlDumper dmp, IDmlfHandler handler) { if (TableOrView != null) { dmp.Put("%f", TableOrView); } if (Alias != null) { dmp.Put(" %i", Alias); } }
public override void GenSql(ISqlDumper dmp) { dmp.Put(" %k(", FuncName); bool was = false; foreach (var arg in Arguments) { if (was) dmp.Put(","); was = true; arg.GenSql(dmp); } dmp.Put(")"); }
//public string GetExpression() //{ // StringBuilder sb = new StringBuilder(); // WriteExpression(sb); // return sb.ToString(); //} public void WriteExpression(ISqlDumper dmp) { if (!Table.Alias.IsEmpty()) { dmp.Put("%i", Table.Alias); } else { dmp.Put("%f", Table.FullName); } dmp.Put(".%i", Name); }
public static void GenSql(this DmlfSortOrderType type, ISqlDumper dmp) { switch (type) { case DmlfSortOrderType.Ascending: dmp.Put("^asc"); break; case DmlfSortOrderType.Descendning: dmp.Put("^desc"); break; } }
public override void GenerateSql(ISqlDumper dmp, IDataSynAdapter sada, SynSourceInfo info, SynQueryType qtype, Action <ISqlDumper> putCondition) { GenerateSqlToFrom(dmp, sada, info, qtype); dmp.Put("("); dmp.WriteRaw(Sql); dmp.Put(") sub"); if (putCondition != null) { putCondition(dmp); } GenerateSqlOrder(dmp, sada, info, qtype); }
public override void GenSql(ISqlDumper dmp) { dmp.Put(" ^row_number() ^over (^order ^by "); bool was = false; foreach (var col in OrderBy) { if (was) dmp.Put(", "); col.GenSql(dmp); was = true; } dmp.Put(")"); }
public override void GenSql(ISqlDumper dmp) { dmp.Put("^insert ^into %f ", InsertTarget); dmp.Put("(%,i) ^ values (", Columns.Select(x => x.TargetColumn)); for (int i = 0; i < Columns.Count; i++) { if (i > 0) dmp.Put(", "); Columns[i].Expr.GenSql(dmp); } dmp.Put(")"); dmp.EndCommand(); }
public override void GenSql(ISqlDumper dmp) { dmp.Put("("); bool was = false; foreach(var item in Items) { if (was) dmp.Put("+"); item.GenSql(dmp); was = true; } dmp.Put(")"); }
public static void PutEditorInfo(ISqlDumper dmp, string editorInfo) { if (editorInfo == null) { return; } dmp.Put("&n-- *** EDITOR-INFO-BEGIN ***&n"); foreach (var line in editorInfo.Split('\n')) { dmp.Put("-- %s&n", line.TrimEnd()); } dmp.Put("-- *** EDITOR-INFO-END ***&n"); }
protected void GenerateFrom(ISqlDumper dmp) { dmp.Put("&n^from &>"); bool wasfromItem = false; foreach (var fromItem in From) { if (wasfromItem) dmp.Put(",&n"); fromItem.GenSql(dmp); wasfromItem = true; } dmp.Put("&<"); }
public override void GenerateSql(ISqlDumper dmp, DbTypeBase targetType) { if (m_dialect == null) { dmp.Put("%:s", Original, m_expr); return; } if (dmp.Dialect.DialectName != m_dialect) { throw new SyntaxNotSupportedError("DAE-00250 Specific expression has other target dialect"); } dmp.Put("%:s", Original, m_expr); }
public static void GenSql(this DmlfSortOrderType type, ISqlDumper dmp) { switch (type) { case DmlfSortOrderType.Ascending: dmp.Put("^asc"); break; case DmlfSortOrderType.Descending: dmp.Put("^desc"); break; } }
private void DownloadFixedData(IDatabaseSource db, DatabaseStructure dbs, IDatabaseStructure pattern) { foreach (var tbl in pattern.Tables) { if (tbl.FixedData == null) { continue; } if (dbs.Tables.GetIndex(tbl.FullName) < 0) { continue; } var t2 = (TableStructure)dbs.Tables[tbl.FullName]; var pk1 = tbl.FindConstraint <IPrimaryKey>(); var pk2 = t2.FindConstraint <IPrimaryKey>(); if (pk1 == null || pk2 == null) { continue; } if (pk1.Columns.Count != pk2.Columns.Count) { continue; } using (DbCommand cmd = db.Connection.SystemConnection.CreateCommand()) { StringWriter sw = new StringWriter(); ISqlDumper dmp = db.Dialect.CreateDumper(sw); dmp.Put("^select * ^from %f ^where 0=1", t2); foreach (var row in tbl.FixedData.Rows) { dmp.Put(" ^or ( "); for (int i = 0; i < pk1.Columns.Count; i++) { if (i > 0) { dmp.Put(" ^and "); } dmp.Put(" %s = %v ", pk1.Columns[i].ColumnName, row.GetValue(tbl.Columns.GetIndex(pk1.Columns[i].ColumnName))); } dmp.Put(" ) "); } cmd.CommandText = sw.ToString(); using (var reader = db.GetAnyDDA().AdaptReader(cmd.ExecuteReader())) { t2.FixedData = new InMemoryTable(t2, reader); } } } }
public override void RenderSql(ISqlDumper dmp) { string prefix = null, joiner = null; switch (CompoudType.SelectedIndex) { case 0: joiner = "AND"; break; case 1: joiner = "OR"; break; case 2: prefix = "NOT"; joiner = "OR"; break; case 3: prefix = "NOT"; joiner = "AND"; break; } if (prefix != null) { dmp.Put(" %k ", prefix); } dmp.Put("("); bool was = false; foreach (var child in Children) { if (!child.IsEnabled) { continue; } if (was) { dmp.Put(" %k ", joiner); } child.RenderSql(dmp); was = true; } if (!was) { dmp.Put("1=1"); } dmp.Put(")"); }
public override void GenSql(ISqlDumper dmp) { LeftExpr.GenSql(dmp); if (CollateSpec != null) { dmp.Put(" ^collate %s ", CollateSpec); } dmp.Put(Relation); RightExpr.GenSql(dmp); if (CollateSpec != null) { dmp.Put(" ^collate %s ", CollateSpec); } }
public override void GenSql(ISqlDumper dmp, IDmlfHandler handler) { var src = Source; if (src == null) { src = handler.BaseTable; } dmp.Put("&n^from &>"); src.GenSqlDef(dmp, handler); dmp.Put(" "); Relations.GenSql(dmp, handler); dmp.Put("&<"); }
public override void GenerateSql(ISqlDumper dmp) { if (IsComma) { dmp.Put("%:s", CommaPos, ","); } dmp.Put("&3n"); Value.GenerateSql(dmp); if (Alias != null) { dmp.Put("&s%:k", AsPos, "as"); Alias.GenerateSql(dmp); } }
protected void DumpColumns(ITableStructure tbl, ISqlDumper dmp) { bool was = false; foreach (var col in tbl.Columns) { if (was) { dmp.Put(",&n"); } dmp.Put("%i", col.ColumnName); was = true; } }
public override void GenSql(ISqlDumper dmp) { dmp.Put("^update "); if (TopRecords != null) dmp.Put("^top(%s) ", TopRecords); if (UpdateTarget != null) UpdateTarget.GenSqlRef(dmp); dmp.Put("&n^set "); Columns.GenSql(dmp); if (dmp.Factory.DialectCaps.AllowUpdateFrom) { GenerateFrom(dmp); } if (Where != null) Where.GenSql(dmp); }
public override void GenSql(ISqlDumper dmp) { Expr.GenSql(dmp); if (_alias != null) { dmp.Put(" ^as %i", _alias); } }
public override void GenSql(ISqlDumper dmp) { dmp.Put("^delete "); if (TopRecords != null) dmp.Put("^top(%s) ", TopRecords); if (dmp.Factory.DialectCaps.AllowDeleteFrom) { if (DeleteTarget != null) DeleteTarget.GenSqlRef(dmp); GenerateFrom(dmp); } else { dmp.Put("^from "); if (DeleteTarget != null) DeleteTarget.GenSqlRef(dmp); } if (Where != null) Where.GenSql(dmp); }
public static void GenSql(this DmlfJoinType join, ISqlDumper dmp) { switch (join) { case DmlfJoinType.Inner: dmp.Put("^inner ^join"); break; case DmlfJoinType.Left: dmp.Put("^left ^join"); break; case DmlfJoinType.Right: dmp.Put("^right ^join"); break; case DmlfJoinType.Outer: dmp.Put("^full ^outer ^join"); break; case DmlfJoinType.CrossApply: dmp.Put("^cross ^apply"); break; case DmlfJoinType.OuterApply: dmp.Put("^outer ^apply"); break; } }
public override void GenSql(ISqlDumper dmp) { LeftExpr.GenSql(dmp); dmp.Put(" ^not ^in "); RightExpr.GenSql(dmp); }
public override void GenSql(ISqlDumper dmp) { dmp.Put("(1=0)"); }
public override void GenSql(ISqlDumper dmp) { Expr.GenSql(dmp); dmp.Put(" ^is ^not ^null"); }
public virtual void GenSqlBegin(ISqlDumper dmp) { dmp.Put("("); }
public override void PutLogMessage( ISqlDumper dmp, string operationExpr, string targetEntityExpr, string messageExpr, string durationExpr, string procedureExpr, string rowsExpr, IShellContext context) { if (String.IsNullOrEmpty(TableName)) return; var fullName = new NameWithSchema(context.Replace(TableSchema), context.Replace(TableName)); var insert = new DmlfInsert(); insert.InsertTarget = fullName; if (!String.IsNullOrEmpty(OperationColumn)) { insert.Columns.Add(new DmlfUpdateField { TargetColumn = OperationColumn, Expr = new DmlfSqlValueExpression { Value = operationExpr }, }); } if (!String.IsNullOrEmpty(MessageColumn)) { insert.Columns.Add(new DmlfUpdateField { TargetColumn = MessageColumn, Expr = new DmlfSqlValueExpression { Value = messageExpr }, }); } if (!String.IsNullOrEmpty(DurationColumn)) { insert.Columns.Add(new DmlfUpdateField { TargetColumn = DurationColumn, Expr = new DmlfSqlValueExpression { Value = durationExpr }, }); } if (!String.IsNullOrEmpty(TargetEntityColumn)) { insert.Columns.Add(new DmlfUpdateField { TargetColumn = TargetEntityColumn, Expr = new DmlfSqlValueExpression { Value = targetEntityExpr }, }); } if (!String.IsNullOrEmpty(MessageDateColumn)) { insert.Columns.Add(new DmlfUpdateField { TargetColumn = MessageDateColumn, Expr = new DmlfSqlValueExpression { Value = "GETDATE()" }, }); } if (!String.IsNullOrEmpty(ImportDateColumn)) { insert.Columns.Add(new DmlfUpdateField { TargetColumn = ImportDateColumn, Expr = SqlScriptCompiler.ImportDateTimeExpression, }); } if (!String.IsNullOrEmpty(ProcedureColumn)) { insert.Columns.Add(new DmlfUpdateField { TargetColumn = ProcedureColumn, Expr = new DmlfSqlValueExpression { Value = procedureExpr }, }); } if (!String.IsNullOrEmpty(RowsColumn)) { insert.Columns.Add(new DmlfUpdateField { TargetColumn = RowsColumn, Expr = new DmlfSqlValueExpression { Value = rowsExpr }, }); } if (insert.Columns.Any()) { insert.GenSql(dmp); dmp.Put("&n"); } }
public virtual void GenSqlEnd(ISqlDumper dmp) { dmp.Put(")"); }
public override void GenSql(ISqlDumper dmp) { dmp.Put("("); LeftExpr.GenSql(dmp); dmp.Put("="); RightExpr.GenSql(dmp); dmp.Put(" ^or "); dmp.Put("("); LeftExpr.GenSql(dmp); dmp.Put("^is ^null"); dmp.Put(" ^and "); RightExpr.GenSql(dmp); dmp.Put(" ^is ^null "); dmp.Put(")"); dmp.Put(")"); }
public override void GenSqlConjuction(ISqlDumper dmp) { dmp.Put(" ^or "); }
public override void GenSql(ISqlDumper dmp) { dmp.Put("^not ^exists ("); Select.GenSql(dmp); dmp.Put(")"); }
public override void GenSql(ISqlDumper dmp) { dmp.Put("&r"); // dump separator if needed dmp.WriteRaw(Value); }
public override void GenSql(ISqlDumper dmp) { if (Conditions.Count == 0) { GenSqlEmpty(dmp); } else { GenSqlBegin(dmp); bool was = false; bool isIndent = false; foreach (var item in Conditions) { if (was) { if (!isIndent) { dmp.Put("&>"); isIndent = true; } dmp.Put("&n"); GenSqlConjuction(dmp); } GenSqlItem(item, dmp); was = true; } GenSqlEnd(dmp); if (isIndent) dmp.Put("&<"); } }
public override void GenSql(ISqlDumper dmp) { Expr.GenSql(dmp); dmp.Put(" "); OrderType.GenSql(dmp); }
public override void GenSql(ISqlDumper dmp) { dmp.Put("("); LeftExpr.GenSql(dmp); if (CollateSpec != null) { dmp.Put(" ^collate %s ", CollateSpec); } dmp.Put("<>"); RightExpr.GenSql(dmp); if (CollateSpec != null) { dmp.Put(" ^collate %s ", CollateSpec); } dmp.Put("^or"); dmp.Put("("); LeftExpr.GenSql(dmp); dmp.Put("^is ^null"); dmp.Put(" ^and"); RightExpr.GenSql(dmp); dmp.Put("^is ^not ^null"); dmp.Put(")"); dmp.Put("or"); dmp.Put("("); LeftExpr.GenSql(dmp); dmp.Put("^is ^not ^null"); dmp.Put(" ^and"); RightExpr.GenSql(dmp); dmp.Put("^is ^null"); dmp.Put(")"); dmp.Put(")"); }
public override void GenSqlEmpty(ISqlDumper dmp) { dmp.Put("(1=1)"); }
public override void GenSql(ISqlDumper dmp) { dmp.Put("(^not("); Expr.GenSql(dmp); dmp.Put("))"); }
public override void GenSql(ISqlDumper dmp) { dmp.Put("^count(^distinct "); Argument.GenSql(dmp); dmp.Put(")"); }
public override void GenSql(ISqlDumper dmp) { Expr.GenSql(dmp); dmp.Put(" ^like %v", "%" + Value + "%"); }