共用方式為


MemberCollection 類別

Gets a read-only, on-demand collection of Member objects contained by a Position, a Level, or a Tuple.

命名空間:  Microsoft.AnalysisServices.AdomdClient
組件:  Microsoft.AnalysisServices.AdomdClient (在 Microsoft.AnalysisServices.AdomdClient.dll 中)

語法

'宣告
Public NotInheritable Class MemberCollection _
    Implements ICollection, IEnumerable
'用途
Dim instance As MemberCollection
public sealed class MemberCollection : ICollection, 
    IEnumerable
public ref class MemberCollection sealed : ICollection, 
    IEnumerable
[<SealedAttribute>]
type MemberCollection =  
    class
        interface ICollection
        interface IEnumerable
    end
public final class MemberCollection implements ICollection, IEnumerable

備註

Although the MemberCollection externally represents a collection of Member objects, the collection is internally loaded and managed in one of two ways, depending on the parent of the collection:

  • If the parent object was referenced as a result of a query, as in the case of a Tuple, the collection represents the members referenced by that query.

  • If the parent object was referenced as a result of a request for metadata, the collection represents the members referenced by the definition of the parent object.

範例

The following subroutine, given a Level, iterates through the MemberCollection and displays information for each member.

Public Overloads Sub ListMembers(ByRef LevelToCheck As Level)

    ' Check the parameter before performing actions on it.
    If LevelToCheck Is Nothing Then
        Throw New System.ArgumentNullException("LevelToCheck")
    Else
        ' Iterate through the Members collection of the
        ' Level object.

        Try
            Dim memberToCheck As Member

            Debug.WriteLine("Found " & LevelToCheck.GetMembers().Count& _
                " member(s) in level:")

            For Each memberToCheck In LevelToCheck.GetMembers()
                Debug.WriteLine("Member:  " & memberToCheck.Name)
                Debug.WriteLine("  Caption:          " & _
                    memberToCheck.Caption)
                Debug.WriteLine("  UniqueName:       " & _
                    memberToCheck.UniqueName)

                ' Note that the Children property loads a collection
                ' of Member objects on demand and
                ' therefore, slows performance when first
                ' referenced--you should instead use the 
                ' ChildCount property.
                Debug.WriteLine("  No. of children:  " & _
                    memberToCheck.ChildCount)
            Next
        Catch ex As AdomdConnectionException
            ' The connection could not be opened or was disconnected.
            ' This error can occur at any time, if the provider is 
            ' disconnected from the server.
            Debug.WriteLine(ex)
            Throw ex
        Catch ex As AdomdErrorResponseException
            ' A response is received from a provider which indicates an error.
            Debug.WriteLine(ex)
            Throw ex
        Catch ex As AdomdUnknownResponseException
            ' A response has been returned from the provider that 
            ' was not understood.
            Debug.WriteLine(ex)
            Throw ex
        Catch ex As AdomdCacheExpiredException
            ' A cached version of an ADOMD.NET object is no longer valid.
            ' This error is typically raised when reviewing metadata.
            Debug.WriteLine(ex)
            Throw ex
        Catch ex As AdomdException
            ' Any other error raised by ADOMD.NET.
            Debug.WriteLine(ex)
            Throw ex
        Catch ex As Exception
            ' Any other error.
            Debug.WriteLine(ex)
            Throw ex        End Try
    End If
End Sub

繼承階層

System. . :: . .Object
  Microsoft.AnalysisServices.AdomdClient..::..MemberCollection

執行緒安全性

這個類型的任何公用static (在 Visual Basic 中為 Shared) 成員都是安全執行緒。不保證任何執行個體成員都可以是安全執行緒。