Server.GetDefaultInitFields(Type) Server.GetDefaultInitFields(Type) Server.GetDefaultInitFields(Type) Method

Definition

Returns the property types that are initialized by default when the specified object is initialized.

public:
 System::Collections::Specialized::StringCollection ^ GetDefaultInitFields(Type ^ typeObject);
public System.Collections.Specialized.StringCollection GetDefaultInitFields (Type typeObject);
Public Function GetDefaultInitFields (typeObject As Type) As StringCollection
Parameters
typeObject
Type Type Type

A Type system object that specifies the type of object.

Returns

A StringCollection system object that contains a list of property types that are initialized by default when the specified object is initialized.

Examples

Visual Basic

PowerShell

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")  
$db = New-Object Microsoft.SqlServer.Management.Smo.Database  
$db = $srv.Databases.Item("AdventureWorks2012")  
$tb = new-object Microsoft.SqlServer.Management.Smo.Table  
$typ = $tb.GetType()  
$sc = $srv.GetDefaultInitFields($typ)  
$srv.SetDefaultInitFields($typ, "CreateDate")  
foreach ($tb in $db.Tables)  
{  
   Write-Host $tb.Schema,".",$tb.Name,".",$tb.CreateDate  
}  
$srv.SetDefaultInitFields($typ, $sc)  

Remarks

This method is used to control the way in which object properties are initialized in an SMO application. You can use this method to optimize your SMO application.

Applies to