Skip to content
Permalink
Browse files

pretty type (#5202)

  • Loading branch information...
potatoqualitee committed Mar 14, 2019
1 parent 7a13ff2 commit cef93eef53234acf7c956b12b7bf7bf2ec5e86b5
Showing with 76 additions and 84 deletions.
  1. +76 −84 xml/dbatools.Types.ps1xml
@@ -1,88 +1,80 @@
<?xml version="1.0" encoding="utf-8" ?>
<Types>
<!--Microsoft.SqlServer.Management.Smo.Database -->
<Type>
<Name>Microsoft.SqlServer.Management.Smo.Database</Name>
<Members>
<ScriptMethod>
<Name>Query</Name>
<Script>
param (
$Query,
<!--Microsoft.SqlServer.Management.Smo.Database -->
<Type>
<Name>Microsoft.SqlServer.Management.Smo.Database</Name>
<Members>
<ScriptMethod>
<Name>Query</Name>
<Script>
param (
$Query,
$AllTables = $false
)
if ($AllTables) { ($this.ExecuteWithResults($Query)).Tables }
else { ($this.ExecuteWithResults($Query)).Tables[0] }
</Script>
</ScriptMethod>
<ScriptMethod>
<Name>Invoke</Name>
<Script>
param (
$Command
)
$this.ExecuteNonQuery($Command)
</Script>
</ScriptMethod>
</Members>
</Type>

$AllTables = $false
)

if ($AllTables) { ($this.ExecuteWithResults($Query)).Tables }
else { ($this.ExecuteWithResults($Query)).Tables[0] }
</Script>
</ScriptMethod>
<ScriptMethod>
<Name>Invoke</Name>
<Script>
param (
$Command
)

$this.ExecuteNonQuery($Command)
</Script>
</ScriptMethod>
</Members>
</Type>

<!--Microsoft.SqlServer.Management.Smo.Server -->
<Type>
<Name>Microsoft.SqlServer.Management.Smo.Server</Name>
<Members>
<ScriptMethod>
<Name>Query</Name>
<Script>
param (
$Query,

$Database,

$AllTables = $false
)
if (-not $Database) {
if ($this.ConnectionContext.DatabaseEngineType -eq "SqlAzureDatabase") {
$Database = $this.ConnectionContext.CurrentDatabase
if (-not $Database) {
$Database = $this.ConnectionContext.SqlConnectionObject.Database
}
}
if (-not $Database) {
$Database = "master"
}
}
if ($AllTables) { ($this.Databases[$Database].ExecuteWithResults($Query)).Tables }
else { ($this.Databases[$Database].ExecuteWithResults($Query)).Tables[0] }
</Script>
</ScriptMethod>
<ScriptMethod>
<Name>Invoke</Name>
<Script>
param (
$Command,

$Database
)

if (-not $Database) {
if ($this.ConnectionContext.DatabaseEngineType -eq "SqlAzureDatabase") {
$Database = $this.ConnectionContext.CurrentDatabase
if (-not $Database) {
$Database = $this.ConnectionContext.SqlConnectionObject.Database
}
}
if (-not $Database) {
$Database = "master"
}
}

$this.Databases[$Database].ExecuteNonQuery($Command)
</Script>
</ScriptMethod>
</Members>
</Type>
<!--Microsoft.SqlServer.Management.Smo.Server -->
<Type>
<Name>Microsoft.SqlServer.Management.Smo.Server</Name>
<Members>
<ScriptMethod>
<Name>Query</Name>
<Script>
param (
$Query,
$Database,
$AllTables = $false
)
if (-not $Database) {
if ($this.ConnectionContext.DatabaseEngineType -eq "SqlAzureDatabase") {
$Database = $this.ConnectionContext.ExecuteScalar("select db_name()")
if (-not $Database) {
$Database = $this.ConnectionContext.SqlConnectionObject.Database
}
}
if (-not $Database) {
$Database = "master"
}
}
if ($AllTables) { ($this.Databases[$Database].ExecuteWithResults($Query)).Tables }
else { ($this.Databases[$Database].ExecuteWithResults($Query)).Tables[0] }
</Script>
</ScriptMethod>
<ScriptMethod>
<Name>Invoke</Name>
<Script>
param (
$Command,
$Database
)
if (-not $Database) {
if ($this.ConnectionContext.DatabaseEngineType -eq "SqlAzureDatabase") {
$Database = $this.ConnectionContext.ExecuteScalar("select db_name()")
if (-not $Database) {
$Database = $this.ConnectionContext.SqlConnectionObject.Database
}
}
if (-not $Database) {
$Database = "master"
}
}
$this.Databases[$Database].ExecuteNonQuery($Command)
</Script>
</ScriptMethod>
</Members>
</Type>
</Types>

0 comments on commit cef93ee

Please sign in to comment.
You can’t perform that action at this time.