ProcessAdd bug in AMO 2016

I saw the question below on the MSDN forum about processAdd not working in AMO 2016 and I thought it sounded strange so I did some investigation:

When I ran Redgate Reflector over the Microsoft.AnalysisServices.Core.dll I came across this little gem:

Where it checks if the object is of a type IQueryBinding from the Miocrosoft.AnalysisServices.Core namespace and as far as I can see nothing currently implements this interface. What this means is that if you pass any of the built-in binding classes to the Process method - it will always throw a NotImplemented exception. 

I've posted a bug here and apparently it's a known issue and a fix is already in the pipeline. However there is also a relatively simple workaround which involves creating a class which implements IQueryBinding in your own project.

The IQueryBinding interface is thankfully not that complicated and a full implementation is outlined below:

public class MyBinding : Microsoft.AnalysisServices.Core.IQueryBinding
        public MyBinding(string dataSourceID, string queryDefinition)
            DataSourceID = dataSourceID;
            QueryDefinition = queryDefinition;
        public string DataSourceID { get; set; }
        public string QueryDefinition { get; set; }
        public ISite Site { get; set; }
        public event EventHandler Disposed;
        public void Dispose() { }

You can then simply create a MyBinding instance and pass this in to the Process method for you your partition:

var qb = new MyBinding("Adventure Works DW", "SELECT * FROM table");
partition.Process(ProcessType.ProcessAdd, qb);

Print | posted on Monday, November 14, 2016 9:26 AM