public override string ToPlainQuery() { StringBuilder sb = new StringBuilder(); if (IfNotExistsQuery != null) { sb.AppendFormat("IF NOT EXISTS ({0})", IfNotExistsQuery.ToPlainQuery()); } sb.AppendFormat(" INSERT INTO {0}", Table); if (InsertColumns.Count > 0) { sb.AppendFormat(" ({0})", String.Join($", ", InsertColumns.Select(r => $"{r.Name}"))); } if (FromQuery == null) { sb.AppendFormat(" VALUES ({0})", String.Join($", ", Enumerable.Range(0, InsertValues.Count).Select(r => $"@insP{r}"))); } else { sb.Append($" {FromQuery.Item1.ToPlainQuery()}"); } if (ElseUpdateQuery != null) { sb.AppendFormat(" ELSE {0}", ElseUpdateQuery.ToPlainQuery()); } return(sb.ToString().Trim()); }
internal override List <Condition> GetConditions() { var listConditions = base.GetConditions(); /// If not exists conditions if (IfNotExistsQuery != null) { listConditions.AddRange(IfNotExistsQuery.GetConditions()); } /// Else update conditions if (ElseUpdateQuery != null) { listConditions.AddRange(ElseUpdateQuery.GetConditions()); } return(listConditions); }