DTSReadOnlyCollectionBase.Count Property

Gets the number of elements contained in the DTSReadOnlyCollectionBase instance.

Namespace:  Microsoft.SqlServer.Dts.Runtime
Assembly:  Microsoft.SqlServer.ManagedDTS (in Microsoft.SqlServer.ManagedDTS.dll)

public int Count { get; }

Property Value

Type: System.Int32
An integer that contains the number of elements contained in the DTSReadOnlyCollectionBase instance.



The following code example shows how an inheriting class, the LogProviders collection, uses the Count property.

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

namespace LogProviders_Tests
    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\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx";

            // Create the Application, and load the sample.
            Application app = new Application();
            Package pkg = app.LoadPackage(mySample, null);
            LogProviders logProvs = pkg.LogProviders;

            // Count the number of providers in the package.
            int countProvs = logProvs.Count;
            Console.WriteLine("Initial number of log providers: {0}", countProvs);

            // Since the package that was loaded only contained the
            // SSIS Log provider for Text files, let's add the SQL
            // Server log provider.
            LogProvider logProv = pkg.LogProviders.Add("DTS.LogProviderSQLServer.2");

            // Count how many log providers are in the collection now.
            countProvs = logProvs.Count;
            Console.WriteLine("The number of log providers now: {0}", countProvs);

            foreach (LogProvider lp in logProvs)
                Console.WriteLine("Log Provider Name: {0}", lp.Name);

Sample Output:

Initial number of log providers: 1

The number of log providers now: 2


Log Provider Name: {FCA3ACD4-C080-4B67-A1AA-45118D3DA672}

Log Provider Name: SSIS log provider for Text files

Community Additions