private object ConvertToColumnDefinitionDDL(NewTableParameters parameters) { List <string> ddl = new List <string>(); string current = ""; var pkre = new Regex(@"\s+primary\s+key($|\s+)"); var hasPk = false; foreach (string item in parameters.Columns) { if (item.StartsWith("-")) { if (!String.IsNullOrEmpty(current)) { hasPk = hasPk || pkre.IsMatch(current); ddl.Add(current); } current = item.TrimStart('-').Replace(":", ""); } else { current += " " + item; } } if (!String.IsNullOrEmpty(current)) { hasPk = hasPk || pkre.IsMatch(current); ddl.Add(current); } if (!hasPk) { ddl.Add("_id integer primary key"); } return(String.Join(", ", ddl.ToArray())); }
private object ConvertToColumnDefinitionDDL(NewTableParameters parameters) { List<string> ddl = new List<string>(); string current = ""; var pkre = new Regex(@"\s+primary\s+key($|\s+)"); var hasPk = false; foreach (string item in parameters.Columns ) { if( item.StartsWith("-")) { if (!String.IsNullOrEmpty(current)) { hasPk = hasPk || pkre.IsMatch(current); ddl.Add(current); } current = item.TrimStart('-').Replace (":", ""); } else { current += " " + item; } } if (!String.IsNullOrEmpty(current)) { hasPk = hasPk || pkre.IsMatch(current); ddl.Add(current); } if (!hasPk) { ddl.Add("_id integer primary key"); } return String.Join(", ", ddl.ToArray()); }