public override string BuildSql(SqlOptions sqlOptions) { var orders = Entities.Select(s => s.BuildSql(sqlOptions, FlowOptions.Construct(this))); var order = string.Join($",{sqlOptions.NewLine()}{sqlOptions.Indent()}", orders); return($"{sqlOptions.Command("ORDER BY")}{sqlOptions.NewLine()}{sqlOptions.Indent()}{order}"); }
public override string BuildSql(SqlOptions sqlOptions) { var columns = string.Join($",{sqlOptions.NewLine()}{sqlOptions.Indent()}", Entities.Select(e => e.BuildSql(sqlOptions, FlowOptions.Construct(this)))); var command = sqlOptions.Command("VALUES"); return $"{command} ({sqlOptions.NewLine()}{sqlOptions.Indent()}{columns}{sqlOptions.NewLine()})"; }
public override string BuildSql(SqlOptions sqlOptions) { var keys = string.Join($",{sqlOptions.NewLine()}{sqlOptions.Indent()}", Entities.Select(e => e.BuildSql(sqlOptions, FlowOptions.Construct(this)))); var command = "RETURNING"; return($"{command}{sqlOptions.NewLine()}{sqlOptions.Indent()}{keys}"); }
public override string BuildSql(SqlOptions sqlOptions) { var entities = Entities.Select(c => $"{c.BuildSql(sqlOptions, FlowOptions.Construct(this))}"); var columns = string.Join($",{sqlOptions.NewLine()}{sqlOptions.Indent()}", entities); var command = sqlOptions.Command("SET"); return($"{command}{sqlOptions.NewLine()}{sqlOptions.Indent()}{columns}"); }
public override string BuildSql(SqlOptions sqlOptions) { var properties = string.Join($",{sqlOptions.NewLine()}{sqlOptions.Indent()}", Entities.Select(e => e.BuildSql(sqlOptions, FlowOptions.Construct(this)))); string command; switch (sqlOptions.DatabaseType) { case SqlDatabaseType.Postgres: case SqlDatabaseType.SqLite: command = sqlOptions.Command("DO UPDATE SET"); break; case SqlDatabaseType.MySql: case SqlDatabaseType.MariaDb: command = sqlOptions.Command("UPDATE"); break; default: return(null); } return($"{command}{sqlOptions.NewLine()}{sqlOptions.Indent()}{properties}"); }
public override string BuildSql(SqlOptions sqlOptions) { AndOperator andBlock; if (Entities.Count == 1 && Entities[0] is AndOperator andOperator) { andBlock = andOperator; } else { andBlock = new AndOperator(Entities); } andBlock.Indent = true; andBlock.NewLine = true; var conditions = andBlock.BuildSql(sqlOptions, FlowOptions.Construct(this)); var command = sqlOptions.Command("WHERE"); return($"{command}{sqlOptions.NewLine()}{sqlOptions.Indent(" ")}{conditions}"); }
public virtual string GetSeparator(SqlOptions sqlOptions) { var r = $"{(NewLine ? sqlOptions.NewLine() : "")}{(Indent ? sqlOptions.Indent() : "")}"; return(string.IsNullOrEmpty(r) ? " " : r); }
public override string BuildSql(SqlOptions sqlOptions) { var columns = string.Join($",{sqlOptions.NewLine()}{sqlOptions.Indent()}", Entities.Select(e => e.BuildSql(sqlOptions, FlowOptions.Construct(this)))); return($"{sqlOptions.Command("SELECT")}{sqlOptions.NewLine()}{sqlOptions.Indent()}{columns}"); }