Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
tabular-example/TestExample/TabularHelper.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
61 lines (56 sloc)
1.7 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Data; | |
using Microsoft.AnalysisServices.AdomdClient; | |
using System.Data.SqlClient; | |
namespace TestExample | |
{ | |
public interface ITabularHelper | |
{ | |
DataTable GetDataTable(string query); | |
void ProcessDatabase(); | |
} | |
public class TabularHelper:ITabularHelper | |
{ | |
private string asConnectionString; | |
public TabularHelper(string asConnectionString) | |
{ | |
this.asConnectionString = asConnectionString; | |
} | |
public DataTable GetDataTable(string query) | |
{ | |
using (AdomdConnection con = new AdomdConnection(asConnectionString)) | |
{ | |
con.Open(); | |
using (AdomdDataAdapter adapter = new AdomdDataAdapter(query, con)) | |
{ | |
DataTable dataTable = new DataTable(); | |
adapter.Fill(dataTable); | |
return dataTable; | |
} | |
} | |
} | |
public void ProcessDatabase() | |
{ | |
using (AdomdConnection con = new AdomdConnection(asConnectionString)) | |
{ | |
con.Open(); | |
string processCommandText = @" | |
{ | |
""refresh"": { | |
""type"": ""full"", | |
""objects"": [ | |
{ | |
""database"": ""validation"" | |
} | |
] | |
} | |
} | |
"; | |
using (AdomdCommand command = new AdomdCommand(processCommandText, con)) | |
{ | |
command.ExecuteNonQuery(); | |
} | |
} | |
} | |
} | |
} |