/// <summary> /// Uses the specified renderer to render this transform. /// </summary> /// <param name="renderer"></param> /// <param name="options"></param> /// <returns></returns> public Statement[] Render(IRenderer renderer, RenderOptions options) { // filter changes according to options var filteredChanges = CollectionUtils.Select(_changes, change => FilterChange(change, options)); // allow the renderer to modify the change set, and then sort the changes appropriately filteredChanges = OrderChanges(renderer.PreFilter(filteredChanges)); var statements = new List<Statement>(); foreach (var change in filteredChanges) { statements.AddRange(change.GetStatements(renderer)); } return statements.ToArray(); }
/// <summary> /// Determines whether specified change should be included in rendering based on specified options. /// </summary> /// <param name="change"></param> /// <param name="options"></param> /// <returns></returns> private static bool FilterChange(RelationalModelChange change, RenderOptions options) { if (options.SuppressForeignKeys) { if (change is AddForeignKeyChange || change is DropForeignKeyChange) return false; } if (options.SuppressIndexes) { if (change is AddIndexChange || change is DropIndexChange) return false; } if (options.SuppressUniqueConstraints) { if (change is AddUniqueConstraintChange || change is DropUniqueConstraintChange) return false; } if (options.SuppressPrimaryKeys) { if (change is AddPrimaryKeyChange || change is DropPrimaryKeyChange) return false; } return true; }