Partitionsdarstellung (tabellarisch)
Zu Funktionszwecken kann eine Tabelle in verschiedene Teilmengen von Zeilen geteilt werden, die zusammengefasst die Tabelle ergeben. Jede dieser Teilmengen ist eine Partition der Tabelle.
Partitionsdarstellung
Im Hinblick auf AMO-Objekte verfügt eine Partitionsdarstellung über eine 1:1-Zuordnungsbeziehung zu Partition, und es sind keine weiteren AMO-Hauptobjekte erforderlich.
Partition in AMO
Wenn Sie eine Partition mithilfe von AMO verwalten, müssen Sie die Measuregruppe suchen, die die Tabelle für das tabellarische Modell darstellt, und von dort aus arbeiten.
Der folgende Codeausschnitt veranschaulicht, wie einer vorhandenen Tabelle für tabellarische Modelle eine Partition hinzugefügt wird.
private void AddPartition(
AMO.Cube modelCube
, AMO.DataSource newDatasource
, string mgName
, string newPartitionName
, string partitionSelectStatement
, Boolean processPartition
)
{
mgName = mgName.Trim();
newPartitionName = newPartitionName.Trim();
partitionSelectStatement = partitionSelectStatement.Trim();
//Validate Input
if (string.IsNullOrEmpty(newPartitionName) || string.IsNullOrWhiteSpace(newPartitionName))
{
MessageBox.Show(String.Format("Partition Name cannot be empty or blank"), "AMO to Tabular message", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (modelCube.MeasureGroups[mgName].Partitions.ContainsName(newPartitionName))
{
MessageBox.Show(String.Format("Partition Name already defined. Duplicated names are not allowed"), "AMO to Tabular message", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(partitionSelectStatement) || string.IsNullOrWhiteSpace(partitionSelectStatement))
{
MessageBox.Show(String.Format("Select statement cannot be empty or blank"), "AMO to Tabular message", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
//Input validated
string partitionID = newPartitionName; //Using partition name as the ID
AMO.Partition currentPartition = new AMO.Partition(partitionID, partitionID);
currentPartition.StorageMode = AMO.StorageMode.InMemory;
currentPartition.ProcessingMode = AMO.ProcessingMode.Regular;
currentPartition.Source = new AMO.QueryBinding(newDatasource.ID, partitionSelectStatement);
modelCube.MeasureGroups[mgName].Partitions.Add(currentPartition);
try
{
modelCube.Update(AMO.UpdateOptions.ExpandFull, AMO.UpdateMode.UpdateOrCreate);
if (processPartition)
{
modelCube.MeasureGroups[mgName].Partitions[partitionID].Process(AMO.ProcessType.ProcessFull);
MessageBox.Show(String.Format("Partition successfully processed."), "AMO to Tabular message", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (AMO.AmoException amoXp)
{
MessageBox.Show(String.Format("AMO exception accessing the server.\nError message: {0}", amoXp.Message), "AMO to Tabular message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
catch (Exception)
{
throw;
}
}
AMO2Tabular-Beispiel
Um jedoch einen Einblick in die Verwendung von AMO zur Erstellung und Bearbeitung von Partitionsdarstellungen zu gewinnen, können Sie den Quellcode im AMO2Tabular-Beispiel einsehen. Das Beispiel ist auf Codeplex verfügbar. Ein wichtiger Hinweis zum Code: Der Code wird nur zur Verdeutlichung für die logischen Konzepte bereitgestellt, die hier erläutert werden, und sollte nicht in einer Produktionsumgebung verwendet oder zu anderen als Lehrzwecken eingesetzt werden.