public void CreateTable(string schema, StoreDefinition table) { var columns = table.Properties.Values.OrderBy(p => p.Order).ToList(); var pkColumn = GetPkColumn(columns[0]); var sql = @$ " CREATE TABLE [{schema}].[{table.Name}] ({pkColumn}, {DATA_COLUMN} nvarchar(max));
private void GenerateTableScript(StringBuilder sb, StoreDefinition table) { sb.AppendLine($"CREATE TABLE {table.Name} ("); foreach (var c in table.Properties.Values.OrderBy(v => v.Order)) { var nullable = c.Nullable ? "?" : ""; var reference = ""; var type = c.Type; if (c.Fk) { reference = $" FK {c.ForeignKeys[0].DefinitionName}.{c.ForeignKeys[0].PropertyName}"; type = c.ForeignKeys[0].Type; } sb.AppendLine($" {c.Name} {type}{nullable}{reference},"); } sb.AppendLine(")"); }