如何使用 .NET 将数据从 ms sql 导入表格模型

How to import data from ms sql to tabular model using .NET

那么是否可以使用 .net 库 adom.net 将数据从 ms sql 导入表格模型 ssas?现在我知道可以使用数据导入向导,但也许不使用向导也可以,但使用 .net 进行制作?

我不确定您是要尝试刷新数据还是向模型添加全新的数据源。但是,对于 .net 库,任何一个都相当简单。

    static void Main(string[] args)
    {
        Server server = new Server();

        server.Connect("Data source=YourSSASServerName;Timeout=7200000;Integrated Security=SSPI");

        Database database = server.Databases.FindByName("YourCubeDBName");

        //
        //process database (load in fresh data from SQL)
        //
        database.Process(ProcessType.ProcessFull);





        //
        // add new data source to model (SQL server)
        //
        database.Model.DataSources.Add(new ProviderDataSource()
        {
            Name = "SQL Server Data Source Example",
            Description = "A data source definition that uses explicit Windows credentials for authentication against SQL Server.",
            ConnectionString = "Provider=SQLNCLI11;Data Source=localhost;Initial Catalog=AdventureWorks2014;Integrated Security=SSPI;Persist Security Info=false",
            ImpersonationMode = Microsoft.AnalysisServices.Tabular.ImpersonationMode.ImpersonateAccount,
            Account = @".\Administrator",
            Password = "P@ssw0rd",
        });


        // 
        // Add the new database object to the server's  
        // Databases connection and submit the changes 
        // with full expansion to the server. 
        // 
        server.Databases.Add(database);
        database.Update(UpdateOptions.ExpandFull);
    }