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:

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/91785c40-a03f-4f46-abc1-9a51ed5e4283/processadd-using-amo-sql-2016-systemnotimplementedexception?forum=sqlanalysisservices

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 https://connect.microsoft.com/SQLServer/feedback/details/3110077 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

Comments on this post

No comments posted yet.

Your comment:

 (will show your gravatar)