LogEntryInfos.Item[Object] 属性

定义

从集合中获取一个 LogEntryInfo 对象。 该 Item[Object] 属性是类的默认索引器 LogEntryInfos ,允许使用 LogEntryInfos 查找值。 语法重写语句。

public:
 property Microsoft::SqlServer::Dts::Runtime::LogEntryInfo ^ default[System::Object ^] { Microsoft::SqlServer::Dts::Runtime::LogEntryInfo ^ get(System::Object ^ index); };
public Microsoft.SqlServer.Dts.Runtime.LogEntryInfo this[object index] { get; }
member this.Item(obj) : Microsoft.SqlServer.Dts.Runtime.LogEntryInfo
Default Public ReadOnly Property Item(index As Object) As LogEntryInfo

参数

index
Object

要在集合中找到的 LogEntryInfo 对象的名称、说明、ID 或索引。

属性值

来自集合的一个 LogEntryInfo 对象。

示例

下面的代码示例使用两种方法从集合中检索项。 第一种方法使用 logInfos[0] 语法检索位于集合的第一个位置的整个对象,并将其放置在对象中 logInfos 。 现在可以像往常一样从 logInfo 对象中检索所有属性。 第二种方法演示如何从集合中的第一个对象检索特定属性。

using System;  
using System.Collections.Generic;  
using System.Text;  
using Microsoft.SqlServer.Dts.Runtime;  

namespace LogEntryInfosTest  
{  
    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 LogEntryInfos from the package.  
            LogEntryInfos logInfos = pkg.LogEntryInfos;  

            //Using the Item method syntax of [x], obtain the   
            //first entry. Also, using the [x] syntax, retrieve a  
            // specific property, the Name.   
            LogEntryInfo logInfo = logInfos[0];  
            String nameOfFirstItem = logInfos[0].Name;  

            //Print the name of the logEntryInfo oabject located  
            //at position [0].  
            Console.WriteLine("The ID of the first log entry is: {0}", logInfo.ID);  
            Console.WriteLine("The Name of the first log entry is: {0}", nameOfFirstItem);  
        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  

Namespace LogEnTryInfosTest  
    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 LogEntryInfos from the package.  
            Dim logInfos As LogEnTryInfos =  pkg.LogEnTryInfos   

            'Using the Item method syntax of [x], obtain the   
            'first entry. Also, using the [x] syntax, retrieve a  
            ' specific property, the Name.   
            Dim logInfo As LogEnTryInfo =  logInfos(0)   
            Dim nameOfFirstItem As String =  logInfos(0).Name   

            'Print the name of the logEntryInfo oabject located  
            'at position [0].  
            Console.WriteLine("The ID of the first log entry is: {0}", logInfo.ID)  
            Console.WriteLine("The Name of the first log entry is: {0}", nameOfFirstItem)  
        End Sub  
    End Class  
End Namespace  

示例输出:

第一个日志条目的 ID 为:{D5BD104A-9504-4087-A742-44B2BD90A09D}

第一个日志条目的名称为:诊断

注解

如果调用 Contains 方法返回 true,则可以使用语法 LogEntryInfo[index]访问集合中的指定元素。 Contains如果返回false,此属性将引发异常。

在 C# 中,此属性是 LogEntryInfos 类的索引器。

适用于