Hi,
I have a SSAS base linked to a Datawarehouse on SQL Server 2005.
I would like to access to member properties of one of my dimensions thanks of 'Member' object proposed by Adomd.net
Unfortunately, the "MemberProperties" collection is empty and I know it should by filled with properties. Is this a known bug of the API ? I downloaded the SP2 but the problem remains.
I could avoid the trouble and directly attack the relational schema but this solution is not very elegant.
This is an exemple of my code :
For Each oNiveau In oConnexionAdomd.Cubes("$" & "MyDimension").Dimensions(1).Hierarchies("MyHierarchy").Levels
oCollectionMembres = oNiveau.GetMembers
For Each oMembre In oNiveau.GetMembers
'Here a specific treatment for all the members
For Each oPropMembre In oMembre.MemberProperties
'Here a specific treatment for all the member properties
Next
Next
Next
Thank in advance if someone can help me.
AP
hello Alexandre,
by default GetMembers method does not request member properties from the server.
However, it has an overload that allows you to specify a list of member properties that should be retrieved.
If you use it, for each member returned by GetMembers() all of the requested member properties would be returned.
for example:
oCollectionMembres = oNiveau.GetMembers(0, Long.MaxValue, New String() {"[Employee].[Employee].[Employee].[Birth Date]"}, filters)
or
oCollectionMembres = oNiveau.GetMembers(0, Long.MaxValue, New String() {oNiveau.LevelProperties("Email Address").UniqueName}, filters)
and in case you need to retrieve all available member properties, you can do something like this (rough sample):
Dim oCollectionMembres As MemberCollection
Dim props(oNiveau.LevelProperties.Count - 1) As String
Dim prop As LevelProperty
Dim index As Integer
index = 0
For Each prop In oNiveau.LevelProperties
props(index) = prop.UniqueName
index = index + 1
Next
Dim filters(-1) As MemberFilter
oCollectionMembres = oNiveau.GetMembers(0, Long.MaxValue, props, filters)
Dim oMembre As Member
For Each oMembre In oCollectionMembres
'Here a specific treatment for all the members
Dim oPropMembre As MemberProperty
For Each oPropMembre In oMembre.MemberProperties
'Here a specific treatment for all the member properties
Debug.WriteLine(oPropMembre.Name)
Next
Next
Notice however, that there might be many member properties defined, and it might slow things down if you retrieve all of them for all members.
if you anticipate that you might need access to member properties for only some (not many) members, then you might just
use member.FetchAllProperties() as needed [you will find the member properties inside member.Properties collection in that case].
FetchAllProperties requires a round trip to the server, so you should decide based on what the actual scenario is whether to request
all properties up front using proper GetMembers overload (if you need them for many members), or request them afterwards with FetchAllProperties (if just for a few).
hope this helps,
Hello Mary,
And a great thanks, it perfectly work.
Effectively, I did not use the overload.
Thank you again.
AP
No comments:
Post a Comment