/// <summary> /// Returns a string that represents the current statement target. /// </summary> /// <returns></returns> protected string GetTarget() { Target.Perform(); var targetStr = string.Empty; var items = target.Items; if (items.Count == 0) { foreach (var col in Context[0]) { targetStr += string.Format(",{0} AS {1}", col, col.Alias); } } else { foreach (var item in items) { if (item is Column) { targetStr += string.Format(",{0} AS {1}", item, (item as Column).Alias); } else if (item is Function) { targetStr += string.Format(",{0} AS {1}", item, (item as Function).Alias); } } } return(targetStr.Substring(1)); }
/// <summary> /// Returns a string that represents the current statement target. /// </summary> /// <returns></returns> protected string GetTarget() { Target.Perform(); var targetStr = string.Empty; var type = ObjectList[0].GetType(); object value = null; if (target.Items.Count == 0) { foreach (var col in Context[0].Columns) { target.Items.Add(col); } } if (ObjectList.Count == 1) { target.Items.ForEach(col => { if (col != null) { value = type.GetProperty((col as Column).Name).GetValue(ObjectList[0]); targetStr += string.Format(",{0} = {1}", col.GetIdentifier(), value.ToSqlValue()); } }); } else if (ObjectList.Count > 1) { target.Items.ForEach(col => { if (col != null) { value = string.Format("[$UPDATE_SOURCE].[{0}]", (col as Column).Name); targetStr += string.Format(",{0} = {1}", col.GetIdentifier(), value); } }); } return(targetStr.Length > 0 ? targetStr.Substring(1) : string.Empty); }
/// <summary> /// /// </summary> /// <returns></returns> protected string GetTargetAlias() { Target.Perform(); var targetStr = string.Empty; var alias = string.Empty; var items = target.Items; if (items.Count == 0) { foreach (var table in Context) { foreach (var column in table) { alias = column.Alias; targetStr += string.Format(",{0}", alias); } } } else { foreach (var item in items) { if (item is Column) { alias = (item as Column).Alias; } else if (item is Function) { alias = (item as Function).Alias; } targetStr += string.Format(",{0}", alias); } } return(targetStr.Substring(1)); }