public override void ExecuteCmdlet() { if (this.IsParameterBound(c => c.WorkspaceObject)) { this.WorkspaceName = this.WorkspaceObject.Name; } if (!this.IsParameterBound(c => c.Name)) { string path = this.TryResolvePath(DefinitionFile); this.Name = Path.GetFileNameWithoutExtension(path); } if (this.ShouldProcess(this.WorkspaceName, String.Format(Resources.SettingSynapseSqlScript, this.Name, this.WorkspaceName))) { string query = this.ReadFileAsText(DefinitionFile); SqlConnection currentConnection = new SqlConnection(); if (this.IsParameterBound(c => c.SqlPoolName)) { if (SqlPoolName.ToLower() == "built-in") { currentConnection.PoolName = "Built-in"; currentConnection.Type = SqlConnectionType.SqlOnDemand; currentConnection.DatabaseName = this.SqlDatabaseName; } else { currentConnection.Type = SqlConnectionType.SqlPool; currentConnection.PoolName = this.SqlPoolName; currentConnection.DatabaseName = this.SqlDatabaseName; } } else { currentConnection.PoolName = "Built-in"; currentConnection.Type = SqlConnectionType.SqlOnDemand; currentConnection.DatabaseName = "master"; } SqlScriptMetadata metadata = new SqlScriptMetadata { Language = "sql" }; SqlScriptContent content = new SqlScriptContent(query); content.CurrentConnection = currentConnection; content.Metadata = metadata; content.ResultLimit = ResultLimit; SqlScript sqlscript = new SqlScript(content); sqlscript.Type = SqlScriptType.SqlQuery; if (this.IsParameterBound(c => c.FolderPath)) { SqlScriptFolder folder = new SqlScriptFolder(); folder.Name = FolderPath; sqlscript.Folder = folder; } if (this.IsParameterBound(c => c.Description)) { sqlscript.Description = Description; } SqlScriptResource sqlscriptResource = new SqlScriptResource(this.Name, sqlscript); WriteObject(new PSSqlScriptResource(SynapseAnalyticsClient.CreateOrUpdateSqlScript(this.Name, sqlscriptResource), this.WorkspaceName)); } }
public PSSqlScriptFolder(SqlScriptFolder sqlscriptFolder) { this.Name = sqlscriptFolder?.Name; }