public override void Generate() { try { if (this.UseSingleFile) { //Process all views var sb = new StringBuilder(); sb.AppendLine("--DO NOT MODIFY THIS FILE. IT IS ALWAYS OVERWRITTEN ON GENERATION."); sb.AppendLine(); var grantSB = new StringBuilder(); foreach (var view in _model.Database.CustomViews.Where(x => x.Generated).OrderBy(x => x.Name)) { var template = new SQLStoredProcedureViewAllTemplate(_model, view, true, grantSB); sb.Append(template.FileContent); } //Tenant Views foreach (var table in _model.Database.Tables.Where(x => x.Generated && x.IsTenant).OrderBy(x => x.Name)) { var template = new SQLSelectTenantViewTemplate(_model, table, grantSB); sb.Append(template.FileContent); } //Add grants sb.Append(grantSB.ToString()); var eventArgs = new ProjectItemGeneratedEventArgs("Views.sql", sb.ToString(), ProjectName, this.ParentItemPath, ProjectItemType.Folder, this, true); eventArgs.Properties.Add("BuildAction", 3); OnProjectItemGenerated(this, eventArgs); } else { //Process all views foreach (var view in _model.Database.CustomViews.Where(x => x.Generated).OrderBy(x => x.Name)) { var grantSB = new StringBuilder(); var template = new SQLStoredProcedureViewAllTemplate(_model, view, false, grantSB); var fullFileName = template.FileName; //Add grants var sb = new StringBuilder(); sb.Append(template.FileContent); sb.Append(grantSB.ToString()); var eventArgs = new ProjectItemGeneratedEventArgs(fullFileName, sb.ToString(), ProjectName, this.ParentItemPath, ProjectItemType.Folder, this, true); eventArgs.Properties.Add("BuildAction", 3); OnProjectItemGenerated(this, eventArgs); } } var gcEventArgs = new ProjectItemGenerationCompleteEventArgs(this); OnGenerationComplete(this, gcEventArgs); } catch (Exception ex) { throw; } }