Server.SetDefaultInitFields Server.SetDefaultInitFields Server.SetDefaultInitFields Method

Definition

Specifies whether all the properties are fetched when objects are instantiated.

Overloads

SetDefaultInitFields(Type, String[]) SetDefaultInitFields(Type, String[]) SetDefaultInitFields(Type, String[])

Specifies the properties that are fetched when objects of the specified type are instantiated.

SetDefaultInitFields(Type, StringCollection) SetDefaultInitFields(Type, StringCollection) SetDefaultInitFields(Type, StringCollection)

Specifies the properties that are fetched when objects of the specified type are instantiated.

SetDefaultInitFields(Type, Boolean) SetDefaultInitFields(Type, Boolean) SetDefaultInitFields(Type, Boolean)

Specifies all the properties are fetched when objects of the specified type are instantiated.

SetDefaultInitFields(Boolean) SetDefaultInitFields(Boolean) SetDefaultInitFields(Boolean)

Specifies that all properties are fetched when objects are instantiated.

Remarks

The SetDefaultInitFields method has several overloads that give you option to set the default initialization fields for a specified type, and for specified properties of the type.

SetDefaultInitFields(Type, String[]) SetDefaultInitFields(Type, String[]) SetDefaultInitFields(Type, String[])

Specifies the properties that are fetched when objects of the specified type are instantiated.

public:
 void SetDefaultInitFields(Type ^ typeObject, ... cli::array <System::String ^> ^ fields);
public void SetDefaultInitFields (Type typeObject, params string[] fields);
Public Sub SetDefaultInitFields (typeObject As Type, ParamArray fields As String())
Parameters
typeObject
Type Type Type

A Type system object value that specifies the type of object.

fields
String[]

A String array value that specifies the property fields that are to be fetched when the 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

SMO optimization allows only the minimum properties to be loaded when an object is created. When uninitialized properties are accessed, SMO makes individual requests to load the information from the instance of SQL Server. You can use this method to adjust which properties are initialized for an object when it is first created to further optimize performance.

SetDefaultInitFields(Type, StringCollection) SetDefaultInitFields(Type, StringCollection) SetDefaultInitFields(Type, StringCollection)

Specifies the properties that are fetched when objects of the specified type are instantiated.

public:
 void SetDefaultInitFields(Type ^ typeObject, System::Collections::Specialized::StringCollection ^ fields);
public void SetDefaultInitFields (Type typeObject, System.Collections.Specialized.StringCollection fields);
Public Sub SetDefaultInitFields (typeObject As Type, fields As StringCollection)
Parameters
typeObject
Type Type Type

A Type system object value that specifies the type of object.

fields
StringCollection StringCollection StringCollection

A StringCollection system object value that specifies the property fields that are to be fetched when the 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

SMO optimization allows only the minimum properties to be loaded when an object is created. When uninitialized properties are accessed, SMO makes individual requests to load the information from the instance of SQL Server. You can use this method to adjust which properties are initialized for an object when it is first created to further optimize performance.

SetDefaultInitFields(Type, Boolean) SetDefaultInitFields(Type, Boolean) SetDefaultInitFields(Type, Boolean)

Specifies all the properties are fetched when objects of the specified type are instantiated.

public:
 void SetDefaultInitFields(Type ^ typeObject, bool allFields);
public void SetDefaultInitFields (Type typeObject, bool allFields);
Public Sub SetDefaultInitFields (typeObject As Type, allFields As Boolean)
Parameters
typeObject
Type Type Type

A Type system object value that specifies the type of object.

allFields
Boolean Boolean Boolean

A Boolean value that specifies whether all the properties are fetched when objects are instantiated.

If True, all the properties are fetched when objects are instantiated.

If False, all objects are set to default behavior.

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

SMO optimization allows only the minimum properties to be loaded when an object is created. When uninitialized properties are accessed, SMO makes individual requests to load the information from the instance of SQL Server. You can use this method to adjust which properties are initialized for an object when it is first created to further optimize performance.

SetDefaultInitFields(Boolean) SetDefaultInitFields(Boolean) SetDefaultInitFields(Boolean)

Specifies that all properties are fetched when objects are instantiated.

public:
 void SetDefaultInitFields(bool allFields);
public void SetDefaultInitFields (bool allFields);
Public Sub SetDefaultInitFields (allFields As Boolean)
Parameters
allFields
Boolean Boolean Boolean

A Boolean value that specifies whether all the properties are fetched when objects are instantiated.

If True, all the properties are fetched when objects are instantiated.

If False, all objects are set to default behavior.

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

SMO optimization allows only the minimum properties to be loaded when an object is created. When uninitialized properties are accessed, SMO makes individual requests to load the information from the instance of SQL Server. You can use this method to adjust which properties are initialized for an object when it is first created to further optimize performance.

Applies to