Hi,
I'm using C#, SQL Server 2005, and AMO to create a series of cubes. Then I want to create essentially what whould be a "Parent Cube" that would contain linked measure groups from all the cubes I previously created. I can create the linked measure groups, and when I browse my "Parent Cube" in the immediate window in Visual Studio 2008 I can see all my linked measure groups. However when I go to Update() the cube with the linked measure groups I get an error stating that my cube contains no measure groups. So I'm confused because I can browse them in the Immediate window and through the watch window.
Here's the C# code I'm using to generate the linked measure groups:
public void CreateLinkedMeasures(string[] cubeSuffixes, string cubePrefix)
{
foreach (string suffix in cubeSuffixes)
{
string childCubeName = cubePrefix.Replace("_LINKED", "");
Database localDatabase = _server.Databases.FindByName(childCubeName + "_" + suffix);
//_cube has the measure groups I want to link to.
_cube = localDatabase.Cubes.FindByName(childCubeName);
foreach (MeasureGroup mg in _cube.MeasureGroups)
{
string name = "BASE_" + cubePrefix + "_" + suffix;
MeasureGroup lmg = _linkedCube.LinkMeasureGroup(mg, localDatabase.ID, name);
lmg.Source.CubeID = _cube.ID;
lmg.Source.Persistence = PersistenceType.Metadata;
}
}
}
This method appears to work because I can see them added to the _linkedCube, but when I run _linkedCube.Update(); I get an error stating that _linkedCube has not measure groups.
Any clues on what I'm doing wrong?
Thanks!
Brian
blog: http://brianhochgurtel.blogspot.com MCTS SharePoint 2007 Administration and Development