我正在从DSO迁移到AMO以获取SSAS。以下是我们如何创建Command并添加自定义属性的小样本,以后我们可以使用DSO进行检索。这是C ++中的当前DSO实现。
CString sWAMeasureName = sMeasureName;
CString sStatement = "Create Member CURRENTCUBE.[Measures].[" + sWAMeasureName + "] as \' " + sExpression + "\', FORMAT_STRING = \'" + sFormat + "\', VISIBLE = 1";
if (pCube->Commands->Find((const char*)sWAMeasureName))
{
pCube->Commands->Remove((const char*)sWAMeasureName);
pCube->Update();
}
_CubeCommandPtr cubeCommand = pCube->Commands->AddNew((const char*)sWAMeasureName, sbclsRegular);
cubeCommand->CommandType = cmdCreateMember;
cubeCommand->Statement = (const char*)sStatement;
cubeCommand->CustomProperties->Add((const char*)sAggrFunction, "AggrFunc", (VbVarType)8 /*vbString*/);
cubeCommand->CustomProperties->Add((const char*)sAggrArg, "AggrArg", (VbVarType)8 /*vbString*/);
cubeCommand->CustomProperties->Add((const char*)sSourceColumn, "SourceColumn", (VbVarType)8 /*vbString*/);
cubeCommand->CustomProperties->Add((const char*)sNumMeasureName, "NumMeasName", (VbVarType)8 /*vbString*/);
cubeCommand->CustomProperties->Add((const char*)sDenMeasureName, "DenMeasName", (VbVarType)8 /*vbString*/);
pCube->Update();
在我们迁移到AMO之后,我需要能够从AMO中的命令(AMO中的mdxscript)对象中检索自定义属性。到目前为止我无法得到它们。我在这做错了什么?这是我在C#中编写的示例代码。
var list = new List<String>();
var cube = GetCubeByName(catalog, sCube);
for (int i = 0; i < cube.MdxScripts.Count; i++)
{
for (int m = 0; m < cube.MdxScripts.Count; m++)
for (int c = 0; c < cube.MdxScripts[i].Commands.Count; c++)
{
foreach (Annotation ann in cube.MdxScripts[i].Annotations)
{
//Doesn't get here
}
foreach (CalculationProperty ann in cube.MdxScripts[i].CalculationProperties)
{
//Doesn't get here
}
}
}