在SSAS 2014 (Ver12)中,我能够用代码处理一个表:
using (Server server = new Server())
{
Database database = server.Databases.FindByName(databaseName);
Table table = database.Model.Tables.Find(tableName);
table.Process(ProcessType.ProcessFull);
}代码引用"Microsoft.AnalysisServices“version="11.0.2100.60”。
然而,在SSAS 2016 (Ver13)中,程序集i引用是Microsoft.AnalysisServices.Server.Tabular.dll.
表对象中不再有进程函数。如何处理新库中的表?
发布于 2016-06-10 22:43:53
要处理SSAS 2016数据库,我需要引用"Microsoft.AnalysisServices.AdomdClient“,并向服务器发送一个JSON命令。
public class TabularProcessor
{
public TabularProcessor(string serverName, string databaseName)
{
this.serverName = serverName;
this.databaseName = databaseName;
this.adomdProcessor = new AdomdProcessor(serverName);
}
private readonly AdomdProcessor adomdProcessor;
private readonly string serverName;
private readonly string databaseName;
public void ProcessTable(string tableName)
{
string commandText = @"{
""refresh"": {
""type"": ""full"",
""objects"": [
{
""database"": ""{database}"",
""table"": ""{table}""
}
]
}
}";
commandText = commandText
.Replace("{database}", databaseName)
.Replace("{table}", tableName);
adomdProcessor.ProcessCommand(commandText);
}
}
public class AdomdProcessor
{
private readonly string serverName;
public AdomdProcessor(string serverName)
{
this.serverName = serverName;
}
public void ProcessCommand(string commandText)
{
AdomdConnection cn = new AdomdConnection("Provider=MSOLAP;Data Source=" + serverName);
cn.Open();
AdomdCommand cmd;
cmd = cn.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = commandText;
cmd.ExecuteNonQuery();
cn.Close();
}
} https://stackoverflow.com/questions/37748582
复制相似问题