Wednesday, March 7, 2012

Programmatic way to replace partition DSV Table bindings with Query Bindings

I'm trying to programmatically replace all my partitions' DSV table bindings with query bindings.

In the partitions manager, when creating a new partition that's restricted via a query binding, the wizard manages to pull a default query from the DSV definition. Is there a way to do this programmatically? The closest thing I could find in the object model is the "Schema" property, but this isn't what I need.

I am pretty sure anything you can do in XMLA is possible to do through AMO.

The easiest way for you to figure out what classes and properties or methods to use is to use AMOBrowser sample application. It shows you the real hierachy of AMO objects.

For instance, using that application I was able to figure out that partition has a source object and then simple search for "partition.source" brought me to this aricle http://msdn2.microsoft.com/en-gb/library/ms345091.aspx

Where I discovered following code sample

static void CreateInternetSalesMeasureGroupPartitions(MeasureGroup mg)
{
Partition part;
part = mg.Partitions.FindByName("Internet_Sales_184");
if ( part != null)
part.Drop();
part = mg.Partitions.Add("Internet_Sales_184");
part.StorageMode = StorageMode.Molap;
part.Source = new QueryBinding(db.DataSources[0].ID, "SELECT * FROM [dbo].[FactInternetSales] WHERE OrderDateKey <= '184'");
part.Slice = "[Date].[Calendar Year].&[2001]";
part.Annotations.Add("LastOrderDateKey", "184");

Edward.
--
This posting is provided "AS IS" with no warranties, and confers no rights.

|||

Thanks for the tip, Edward. I still haven't found the class that exposes the DSV's query binding (which I would use when generating a new partition's query binding), so I suppose I might have to do this manually.

The Annotations property looks pretty useful though, thanks!

No comments:

Post a Comment