Proprietà Item (ICollection)
Gets the specified Cell from the collection by an ICollection interface that contains a collection of absolute axis indexes. In Microsoft Visual C#, this property is the indexer for the CellCollection class.
Spazio dei nomi Microsoft.AnalysisServices.AdomdClient
Assembly: Microsoft.AnalysisServices.AdomdClient (in Microsoft.AnalysisServices.AdomdClient.dll)
Sintassi
'Dichiarazione
Public ReadOnly Default Property Item ( _
indexes As ICollection _
) As Cell
Get
'Utilizzo
Dim instance As CellCollection
Dim indexes As ICollection
Dim value As Cell
value = instance(indexes)
public Cell this[
ICollection indexes
] { get; }
public:
property Cell^ default[ICollection^ indexes] {
Cell^ get (ICollection^ indexes);
}
member Item : Cell
JScript supporta l'utilizzo di proprietà indicizzate, ma non la dichiarazione di nuove proprietà.
Parametri
- indexes
Tipo: System.Collections. . :: . .ICollection
An ICollection that contains a number of elements less than or equal to the count of axes in the CellSet referenced by the collection.
Valore proprietà
Osservazioni
The ICollection represents a tuple created by referencing a single point from each axis represented in the CellSet referenced by the collection. The index of each element in the ICollection matches the index of each axis in the Axes collection of the CellSet, and the value of each element represents a zero-based index of rows for each axis.
The following diagram illustrates the Axes collection of a CellSet. The Axes collection contains three axes, numbered from 0 to 2. A single tuple from each axis is then selected to identify a tuple representing a single Cell.
Tuple 4 is selected from Axes.Item(0), tuple 2 is selected from Axes.Item(1), and tuple 5 is selected from Axes.Item(2). Therefore, the ICollection should contain three elements, also numbered from 0 to 2 and assigned the values 4, 2, and 5, respectively.
If the ICollection contains more elements than the Axes collection, an exception is thrown.
For more information about the ICollection interface, see System.Collections..::..ICollection.
Examples
The following example shows a wrapper function that, given a CellSet and a list of axis indexes, safely calls the Item property using an ICollection:
Public Function GetCellByArray(_
ByRef CellSetToUse As CellSet, _
ByVal ParamArray AxisIndexes() As Int32) As Cell
' Trap the various errors that can occur when
' retrieving a Cell object reference using an ICollection.
If CellSetToUse Is Nothing Then
Throw New System.ArgumentNullException("CellSetToUse")
ElseIf AxisIndexes Is Nothing Then
Throw New System.ArgumentNullException("AxisIndexes")
ElseIf AxisIndexes.Length = 0 Then
Throw New System.ArgumentNullException("AxisIndexes")
ElseIf AxisIndexes.Length > CellSetToUse.Axes.Count Then
Throw New System.ArgumentOutOfRangeException("AxisIndexes")
Else
Try
' Cast the ParamArray object as an ICollection object,
' just to be safe.
Dim AxisArrayList As New ICollection(AxisIndexes)
Return CellSetToUse.CellCollection.Item(AxisArrayList)
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 Function
The following example shows a function that, given a CellSet and a list of axis indexes, calculates the index of a Cell within the CellCollection collection.
Public Function GetCellIndexFromAxisIndexes(_
ByRef CellSetToUse As CellSet, _
ByVal ParamArray AxisIndexes() As Int32) As Int32
' Trap the various errors that can occur when
' calculating a Cell index using an ICollection.
If CellSetToUse Is Nothing Then
Throw New System.ArgumentNullException("CellSetToUse")
ElseIf AxisIndexes.Length = 0 Then
Throw New System.ArgumentNullException("AxisIndexes")
ElseIf AxisIndexes.Length > CellSetToUse.Axes.Count Then
Throw New System.ArgumentOutOfRangeException("AxisIndexes")
Else
Dim currentIndex As Int32 = 0
Dim currentOrdinal As Int32 = 0
Dim currentMultiple As Int32 = 1
Try
For currentIndex = 0 To AxisIndexes.Length - 1
currentOrdinal += currentMultiple * AxisIndexes(currentIndex)
currentMultiple *= CellSetToUse.Axes(currentIndex).Tuples.Count
Next
Catch e As System.Exception
Throw e
End Try
Return currentOrdinal
End If
End Function
Vedere anche