/// <summary> /// Returns a SQL-string that represents the current object. /// </summary> /// <returns></returns> public override string ToSql() { var sql = string.Format("DELETE {0}FROM {1} ", GetParameters(), Context[0]); Clauses.ForEach(clause => sql += clause.ToSql()); return(sql); }
/// <summary> /// Returns a SQL-string that represents the current object. /// </summary> /// <returns></returns> public override string ToSql() { var union = HasUnion.HasValue ? HasUnion == UnionType.Union ? "UNION " : "UNION ALL " : string.Empty; var sql = string.Format("{0}SELECT {1}{2} FROM {3} ", union, GetParameters(), GetTarget(), Context[0]); Clauses.ForEach(clause => sql += clause.ToSql()); return(sql); }
public CalculatedImmediateTmsOperand(List <object> sourceClauses, bool shiftLeft) { Clauses = sourceClauses.ToList(); if (shiftLeft) { Clauses.Add(Z80AssemblyParsing.Operands.MathOperator.TIMES); Clauses.Add((ushort)0x100); } var sb = new StringBuilder(); Clauses.ForEach(clause => sb.Append(GetString(clause))); DisplayValue = sb.ToString(); }
/// <summary> /// Returns a SQL-string that represents the current object. /// </summary> /// <returns></returns> public override string ToSql() { var targetStr = GetTarget(); if (targetStr.Length == 0) { return(string.Empty); } var sql = string.Format("UPDATE {0} SET {1} FROM {0} ", Context[0], targetStr); if (ObjectList.Count > 0 && !string.IsNullOrWhiteSpace(JoinOnPrimaryKey)) { var type = ObjectList[0].GetType(); var values = string.Empty; var val = string.Empty; var items = string.Empty; ObjectList.ForEach(obj => { val += string.Format(",{0}", type.GetProperty(JoinOnPrimaryKey).GetValue(obj).ToSqlValue()); target.Items.ForEach(item => { val += string.Format(",{0}", type.GetProperty((item as Column).Name).GetValue(obj).ToSqlValue()); }); values += string.Format(",({0})", val.Substring(1)); val = string.Empty; }); target.Items.ForEach(item => { if (item != null) { items += string.Format(",[{0}]", (item as Column).Name); } }); sql += string.Format("JOIN (VALUES {0}) AS [$UPDATE_SOURCE] ([{1}],{2}) ON {3} = [$UPDATE_SOURCE].[{1}] ", values.Substring(1), JoinOnPrimaryKey, items.Substring(1), Context[0][JoinOnPrimaryKey]); } if (Clauses.Count > 0) { Clauses.ForEach(clause => sql += clause.ToSql()); } return(sql); }