@@ -12,18 +12,18 @@ var options = new
1212 DataSource = Path.Combine(Path.GetDirectoryName(Host.TemplateFile), "_Xml", "ChinookData.xml"),
1313 DdlStrategies = new IDdlStrategy[]
1414 {
15- new SqlServerStrategy { IsIdentityEnabled = false , Encoding = Encoding.Unicode },
16- new SqlServerStrategy { IsIdentityEnabled = true , Encoding = Encoding.Unicode },
17- new SqlServerCompactStrategy { IsIdentityEnabled = false },
18- new SqlServerCompactStrategy { IsIdentityEnabled = true },
19- new SqliteStrategy { IsIdentityEnabled = false },
20- new SqliteStrategy { IsIdentityEnabled = true , PrimaryKeyDef = KeyDefinition.OnCreateTableColumn },
21- new MySqlStrategy { IsIdentityEnabled = false },
22- new MySqlStrategy { IsIdentityEnabled = true },
23- new OracleStrategy { IsIdentityEnabled = false , Encoding = Encoding.UTF8 },
24- new PostgreSqlStrategy { IsIdentityEnabled = false , Encoding = Encoding.Default },
25- new PostgreSqlStrategy { IsIdentityEnabled = true , Encoding = Encoding.Default },
26- new Db2Strategy { IsIdentityEnabled = false , Encoding = Encoding.Default }
15+ new SqlServerStrategy { PrimaryKeyStrategy = PrimaryKeyStrategy.None , Encoding = Encoding.Unicode },
16+ new SqlServerStrategy { PrimaryKeyStrategy = PrimaryKeyStrategy.Identity , Encoding = Encoding.Unicode },
17+ new SqlServerCompactStrategy { PrimaryKeyStrategy = PrimaryKeyStrategy.None },
18+ new SqlServerCompactStrategy { PrimaryKeyStrategy = PrimaryKeyStrategy.Identity },
19+ new SqliteStrategy { PrimaryKeyStrategy = PrimaryKeyStrategy.None },
20+ new SqliteStrategy { PrimaryKeyStrategy = PrimaryKeyStrategy.Identity , PrimaryKeyDef = KeyDefinition.OnCreateTableColumn },
21+ new MySqlStrategy { PrimaryKeyStrategy = PrimaryKeyStrategy.None },
22+ new MySqlStrategy { PrimaryKeyStrategy = PrimaryKeyStrategy.Identity },
23+ new OracleStrategy { PrimaryKeyStrategy = PrimaryKeyStrategy.None , Encoding = Encoding.UTF8 },
24+ new PostgreSqlStrategy { PrimaryKeyStrategy = PrimaryKeyStrategy.None , Encoding = Encoding.Default },
25+ new PostgreSqlStrategy { PrimaryKeyStrategy = PrimaryKeyStrategy.Identity , Encoding = Encoding.Default },
26+ new Db2Strategy { PrimaryKeyStrategy = PrimaryKeyStrategy.None , Encoding = Encoding.Default }
2727 },
2828 OutputFiles = new List<OutputFile>()
2929};
@@ -44,7 +44,7 @@ foreach (IDdlStrategy strategy in options.DdlStrategies)
4444 var filename = GetFileName(strategy, strategy.ScriptFileExtension);
4545 fileManager.StartNewFile(filename, strategy.Encoding);
4646
47- var details = (strategy.IsIdentityEnabled ? "Auto incremented primary keys." : string.Empty);
47+ var details = (strategy.PrimaryKeyStrategy == PrimaryKeyStrategy.Identity ? "Auto incremented primary keys." : string.Empty);
4848
4949 // Add the script file to the package list.
5050 options.OutputFiles.Add(new OutputFile { Name = filename, Package = strategy.Name, Description = "SQL script to create the Chinook database. " + details });
@@ -285,7 +285,7 @@ CREATE INDEX <#= ifkName #> ON <#= strategy.GetFullyQualifiedName(fromTableName)
285285 foreach (DataColumn col in table.Columns)
286286 {
287287 string value = row[col.ColumnName].ToString();
288- if ((col.AutoIncrement && strategy.IsIdentityEnabled ) || value.Length==0) continue;
288+ if ((col.AutoIncrement && strategy.PrimaryKeyStrategy != PrimaryKeyStrategy.None ) || value.Length==0) continue;
289289
290290 if (col.DataType == typeof(DateTime))
291291 {
@@ -453,8 +453,13 @@ public class OutputFile {
453453
454454private static string GetFileName(IDdlStrategy strategy, string extension)
455455{
456- var suffix = (strategy.IsIdentityEnabled ? "_AutoIncrementPKs" : string.Empty);
457- return string.Format("Chinook_{0}{1}.{2}", strategy.Name, suffix, extension);
456+ var suffix = strategy.PrimaryKeyStrategy switch {
457+ PrimaryKeyStrategy.Identity => "_AutoIncrementPKs",
458+ PrimaryKeyStrategy.Serial => "_SerialPKs",
459+ _ => string.Empty
460+ };
461+
462+ return $"Chinook_{strategy.Name}{suffix}.{extension}";
458463}
459464
460465private static string GetValues(IEnumerable<string> values, char delimiter)
0 commit comments