ExtendedProperties.Item[Object] Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene un ExtendedProperty oggetto dalla raccolta.
public:
property Microsoft::SqlServer::Dts::Runtime::ExtendedProperty ^ default[System::Object ^] { Microsoft::SqlServer::Dts::Runtime::ExtendedProperty ^ get(System::Object ^ index); };
public Microsoft.SqlServer.Dts.Runtime.ExtendedProperty this[object index] { get; }
member this.Item(obj) : Microsoft.SqlServer.Dts.Runtime.ExtendedProperty
Default Public ReadOnly Property Item(index As Object) As ExtendedProperty
Parametri
- index
- Object
Il nome, la descrizione, l'ID o l'indice dell'oggetto ExtendedProperty da restituire.
Valore della proprietà
Un ExtendedProperty oggetto della collezione.
Esempio
Il seguente esempio di codice recupera un elemento dalla collezione utilizzando due metodi. Il primo metodo utilizza la myExtProps[0] sintassi per recuperare l'intero oggetto situato nella prima posizione della collezione e inserirlo nell'oggetto myExtProp . Ora puoi recuperare tutte le proprietà dall'oggetto myExtProp come al solito. Il secondo metodo dimostra come recuperare una proprietà specifica, DataType, dal primo oggetto della collezione.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;
namespace ExtendedProperties_Testing
{
class Program
{
static void Main(string[] args)
{
// The package is one of the SSIS samples.
string mySample = @"C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx";
// Create the application, and load the sample.
Application app = new Application();
Package pkg = app.LoadPackage(mySample, null);
// Get the extended properties collection from the package.
ExtendedProperties myExtProps = pkg.ExtendedProperties;
//Using the Item method syntax of [x], obtain the
// entire first entry, and then just the name.
ExtendedProperty myExtProp = myExtProps[0];
String dataTypeOfFirstItem = myExtProps[0].DataType.ToString();
//Print the name of the extended property
//located at position [0].
Console.WriteLine("The ID of the first item is: {0}", myExtProp.ID);
Console.WriteLine("The DataType of the first item is: {0}", dataTypeOfFirstItem);
Console.WriteLine();
}
}
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Namespace ExtendedProperties_Testing
Class Program
Shared Sub Main(ByVal args() As String)
' The package is one of the SSIS samples.
Dim mySample As String = "C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx"
' Create the application, and load the sample.
Dim app As Application = New Application()
Dim pkg As Package = app.LoadPackage(mySample,Nothing)
' Get the extended properties collection from the package.
Dim myExtProps As ExtendedProperties = pkg.ExtendedProperties
'Using the Item method syntax of [x], obtain the
' entire first entry, and then just the name.
Dim myExtProp As ExtendedProperty = myExtProps(0)
Dim dataTypeOfFirstItem As String = myExtProps(0).DataType.ToString()
'Print the name of the extended property
'located at position [0].
Console.WriteLine("The ID of the first item is: {0}", myExtProp.ID)
Console.WriteLine("The DataType of the first item is: {0}", dataTypeOfFirstItem)
Console.WriteLine()
End Sub
End Class
End Namespace
Output di esempio:
L'ID del primo oggetto è: {F3B7314E-DB1E-4CCA-A856-2E617A1B3265}
Il DataType del primo elemento è: Stringa
Commenti
Se la chiamata al Contains metodo restituisce true, puoi accedere all'elemento specificato nella collezione usando la sintassi ExtendedProperties[index]. Tuttavia, se il Contains metodo restituisce false, questa proprietà crea un'eccezione. In C# questa proprietà è l'indicizzatore per la ExtendedProperties classe .