Exception when referencing SSAS Tabular model in C#

Viewed 1485

I am attempting to automate partition refreshes in Azure Analysis Services via C#. I have installed and referenced the latest 'Microsoft.AnalysisServices. ..' assemblies found here:

https://docs.microsoft.com/en-us/azure/analysis-services/analysis-services-data-providers.

I then have the following code:

using System; using Microsoft.AnalysisServices.Tabular;

    public void Run()
    {
        Server asSrv = new Server();

        try
        {

            asSrv.Connect(ASConnectionString);
            Database db = asSrv.Databases.FindByName("HospoIQTabular");
            Model m = db.Model;

            // only refresh 2017 partitions

            m.Tables["Sales"].Partitions["Sales - Post 2017"].RequestRefresh(RefreshType.Full);
            m.Tables["Payments"].Partitions["Payments - Post 2017"].RequestRefresh(RefreshType.Full);

            db.Model.SaveChanges();     // commit which will execute the refresh

        }
        catch (Exception e)
        {
            OnEventLog(e.Message);
        }
        finally
        {
            asSrv.Disconnect();
            asSrv = null;
        }

    }

Connect to the server and database itself works fine. However, attempting to reference 'db.Model' throws the following exception:

The value '2' is unexpected for type 'DataSourceType'.

I've looked but can't find any help anywhere on this. Any thoughts??

2 Answers
Related