The foundational library for TabuLynx, providing core abstractions and utilities for interacting with Tabular Models.
$ dotnet add package TabuLynx.CoreThe foundational library for the TabuLynx ecosystem, providing core abstractions, interfaces, and utilities for building applications that interact with Analysis Services Tabular Models, Power BI datasets, SSAS, and Microsoft Fabric.
IQueryExecutor, IConnection) for building TabuLynx applicationsTabuLynxOptions for connection settingsTabuLynxHostdotnet add package TabuLynx.Core
This package provides foundational functionality and depends on:
Note: TabuLynx.Core provides the foundation that other TabuLynx packages build upon. You'll typically use this alongside packages like
TabuLynx.Query.ExecutororTabuLynx.Model.Extractor.
appsettings.json:
{
"TabuLynx": {
"ConnectionString": "Provider=MSOLAP;Data Source=localhost:12345;"
}
}
Console Application:
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using TabuLynx.Core.Configuration;
using TabuLynx.Core.Interfaces;
using TabuLynx.Core.Connection;
var configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();
var services = new ServiceCollection();
// Configure TabuLynx options
services.Configure<TabuLynxOptions>(configuration.GetSection("TabuLynx"));
// Register core services
services.AddSingleton<IConnection, TabuLynxConnection>();
var serviceProvider = services.BuildServiceProvider();
// Use the connection
var connection = serviceProvider.GetRequiredService<IConnection>();
Console.WriteLine($"Connection: {connection.ConnectionString}");
using TabuLynx.Core.Hosting;
using TabuLynx.Core.Interfaces;
using Microsoft.Extensions.DependencyInjection;
var host = TabuLynxHost.CreateDefaultBuilder(args)
.ConfigureAppConfiguration(config =>
{
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
})
.ConfigureServices((context, services) =>
{
// TabuLynxOptions are automatically configured and validated
services.AddSingleton<IConnection, TabuLynxConnection>();
// Add other TabuLynx services here
// services.AddAdomdQueryExecutorForLocalPowerBI();
// services.AddDmvModelExtractor();
})
.Build();
var connection = host.Services.GetRequiredService<IConnection>();
using TabuLynx.Core.Configuration;
using TabuLynx.Core.Interfaces;
using TabuLynx.Core.Connection;
var builder = WebApplication.CreateBuilder(args);
// Configure TabuLynx
builder.Services.Configure<TabuLynxOptions>(
builder.Configuration.GetSection("TabuLynx"));
// Register core services
builder.Services.AddSingleton<IConnection, TabuLynxConnection>();
var app = builder.Build();
app.MapGet("/connection", (IConnection connection) =>
{
return Results.Ok(new
{
HasConnectionString = !string.IsNullOrEmpty(connection.ConnectionString),
HasTenantId = !string.IsNullOrEmpty(connection.TenantId),
HasClientId = !string.IsNullOrEmpty(connection.ClientId)
});
});
app.Run();
The TabuLynxOptions class supports comprehensive configuration for different scenarios:
| Property | Description | Required | Default | Example |
|---|---|---|---|---|
ConnectionString | XMLA/ADOMD connection string | Yes | - | Provider=MSOLAP;Data Source=localhost:{port}; |
TenantId | Azure AD tenant ID | For cloud scenarios | "" | 12345678-1234-1234-1234-123456789012 |
ClientId | Azure AD application client ID | For cloud scenarios | "" | 87654321-4321-4321-4321-210987654321 |
ClientSecret | Azure AD application secret | For cloud scenarios | "" | your-client-secret |
Scope | OAuth scope for authentication | No | https://analysis.windows.net/powerbi/api/.default | Custom scope if needed |
Local Power BI Desktop:
{
"TabuLynx": {
"ConnectionString": "Provider=MSOLAP;Data Source=localhost:{port};"
}
}
SSAS Server with Windows Authentication:
{
"TabuLynx": {
"ConnectionString": "Provider=MSOLAP;Data Source=your-server;Initial Catalog=your-database;Integrated Security=SSPI;"
}
}
Microsoft Fabric / Power BI Premium:
{
"TabuLynx": {
"ConnectionString": "Provider=MSOLAP;Data Source=powerbi://api.powerbi.com/v1.0/myorg/your-workspace;Initial Catalog=your-dataset;",
"TenantId": "your-tenant-id",
"ClientId": "your-app-client-id",
"ClientSecret": "your-app-client-secret"
}
}
Defines the contract for executing queries against Analysis Services:
public interface IQueryExecutor
{
Task<string> ExecuteQueryAsync(string query);
Task<List<Dictionary<string, object>>> ExecuteQueryWithDictionaryResultsAsync(string query);
}
Usage:
// Implemented by TabuLynx.Query.Executor package
var result = await queryExecutor.ExecuteQueryAsync("EVALUATE ROW(\"Hello\", \"World\")");
var dictResults = await queryExecutor.ExecuteQueryWithDictionaryResultsAsync("SELECT * FROM $SYSTEM.TMSCHEMA_TABLES");
Provides connection configuration and authentication details:
public interface IConnection
{
string ConnectionString { get; set; }
string TenantId { get; set; }
string ClientId { get; set; }
string ClientSecret { get; set; }
string Scope { get; set; }
}
Usage:
public class CustomService
{
private readonly IConnection _connection;
public CustomService(IConnection connection)
{
_connection = connection;
}
public void DoSomething()
{
var connectionString = _connection.ConnectionString;
// Use connection details...
}
}
using TabuLynx.Core.Hosting;
using TabuLynx.Core.Interfaces;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
// Create and configure host
var host = TabuLynxHost.CreateDefaultBuilder(args)
.ConfigureAppConfiguration(config =>
{
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
config.AddEnvironmentVariables();
})
.ConfigureServices((context, services) =>
{
// Add logging
services.AddLogging(builder => builder.AddConsole());
// Core TabuLynx services (automatically configured)
services.AddSingleton<IConnection, TabuLynxConnection>();
// Add other TabuLynx packages
// services.AddAdomdQueryExecutorForLocalPowerBI();
// services.AddDmvModelExtractor();
// Add your custom services
services.AddTransient<MyDataService>();
})
.Build();
// Use services
var dataService = host.Services.GetRequiredService<MyDataService>();
await dataService.ProcessDataAsync();
public class MyDataService
{
private readonly IConnection _connection;
private readonly ILogger<MyDataService> _logger;
public MyDataService(IConnection connection, ILogger<MyDataService> logger)
{
_connection = connection;
_logger = logger;
}
public async Task ProcessDataAsync()
{
_logger.LogInformation("Processing data with connection: {ConnectionString}",
_connection.ConnectionString);
// Your business logic here
}
}
public void ConfigureTabuLynx(IServiceCollection services, IConfiguration configuration)
{
var environment = configuration["Environment"];
// Configure based on environment
switch (environment?.ToLower())
{
case "development":
services.Configure<TabuLynxOptions>(options =>
{
options.ConnectionString = "Provider=MSOLAP;Data Source=localhost:12345;";
});
break;
case "production":
services.Configure<TabuLynxOptions>(configuration.GetSection("TabuLynx"));
break;
}
services.AddSingleton<IConnection, TabuLynxConnection>();
}
public class CustomConnection : IConnection
{
public string ConnectionString { get; set; } = "";
public string TenantId { get; set; } = "";
public string ClientId { get; set; } = "";
public string ClientSecret { get; set; } = "";
public string Scope { get; set; } = "";
public CustomConnection(IConfiguration configuration)
{
// Custom configuration logic
ConnectionString = configuration.GetConnectionString("TabuLynx") ?? "";
// ... other custom initialization
}
}
// Register custom implementation
services.AddSingleton<IConnection, CustomConnection>();
using System.ComponentModel.DataAnnotations;
// Custom validation for TabuLynxOptions
services.PostConfigure<TabuLynxOptions>(options =>
{
if (string.IsNullOrWhiteSpace(options.ConnectionString))
{
throw new ValidationException("ConnectionString is required");
}
// Cloud scenarios require authentication details
if (options.ConnectionString.Contains("powerbi://") &&
(string.IsNullOrWhiteSpace(options.TenantId) ||
string.IsNullOrWhiteSpace(options.ClientId)))
{
throw new ValidationException("Cloud connections require TenantId and ClientId");
}
});
Configuration Not Found: Ensure your appsettings.json has the correct TabuLynx section:
{
"TabuLynx": {
"ConnectionString": "your-connection-string"
}
}
Validation Errors: Check that required configuration values are provided based on your target platform.
DI Registration Order: Register TabuLynx.Core services before other TabuLynx packages that depend on them.
TabuLynx.Core serves as the foundation for:
Example complete setup:
services.Configure<TabuLynxOptions>(configuration.GetSection("TabuLynx"));
services.AddSingleton<IConnection, TabuLynxConnection>(); // Core
services.AddAdomdQueryExecutorForLocalPowerBI(); // Query.Executor
services.AddDmvModelExtractor(); // Model.Extractor
Contributions, issues, and feature requests are welcome! Please feel free to check the issues page.
This project is licensed under the terms specified in the LICENSE file.