Provides a DbConnectionFactory compliant adapter for the ADOMDX client library.

A new release is now available! Download today!

Features

  • DbProviderFactory compliant
  • Full support for building connection strings via the MdxConnectionStringBuilder
  • ADOMDX 10.0 Compliant wrapper
  • Supports both .Net 3.5 and 4.0 runtimes

Overview

The goal of the MDX Client Adapter to make it easier for .Net developers to construct maintainable analytical data applications following best practices for ADO.Net based components of the BCL. Support for common System.Data paradigms such as factory support from the DbProviderFactory and the ability to support runtime construction of connection strings for SQL Analysis Services are simply not possible with the current incarnation of the Analysis Services Client. Specifically the former goal requires a concrete type used in the object model hierarchy and the latter is simply missing in toto from the provided assembly. In addition, the desire is to extend support for these best practices to the client library instead of subverting or replacing existing functionality of the Analysis Services Client in order to minimize the chance of bugs and feature regression.

The MDX Client Adapter meets these goals by way of the simple to understand and powerful Gang of Four, Adapter design pattern. By wrapping the existing functionality, the MDX Client Adapter bridges the object model hierarchy mismatch with the existing Analysis Services Client but delegates all functionality to the underlying components. This enables a high degree of reliability and behavioral similarity to the original library reducing the overhead of adoption.

Usage

The MDX Client Adapter is primarily used in the following ways:

Supporting the DbProviderFactory
Delegation of factory logic to the common provider factory system can easily be added to your applications via:

1. Add the required information for your configuration file
<system.data>
  <DbProviderFactories>
    <!-- Note that in this example we are using the 4.0 version -->
    <add name="MDX Adapter Data Provider"
     invariant="System.Data.MdxClient" 
     description=".Net Framework Adapter for SqlServer Analysis Services" 
     type="System.Data.MdxClient.MdxClientFactory, System.Data.MdxClient, 
     Version=4.0.4030.34089, Culture=neutral, PublicKeyToken=4ceb5a256399dcae"
    />
  </DbProviderFactories>
</system.data>

note: This information can be added to the machine.config file instead of your application configuration. This is only recomended if you have an existing managament policy and procedures for supporting common configuration extensions on your server environment. In practice, where this configuration goes is inconsequential for client development.

2. Add the providerName attribute to your connectionStrings element for your application Analysis Server.
<connectionStrings>
  <add name="Your Application"
   connectionString="Your Connection String"
   providerName="System.Data.MdxClient"/>
</connectionStrings>


3. Use the .Net Configuration System to acquire the name of the provider
var myConnectionString = ConfigurationManager.ConnectionStrings["Your Application"];
// Note that this code snippet does not show proper best practices for interaction with the ConfigurationManager
// type and is written this way for brevity.


4. Update your code to acquire a DbProviderFactory
var providerName = myConnectionString.ProviderName;
var factory = DbProviderFactory.GetFactory(providerName);
// Note that this code does not show proper checks for confirming proper configuration of the application has
// been performed and is written this way for brevity.


5. Acquire the IDbConnection instance as configured and initialize the connection string
var connection = factory.CreateConnection();
connection.ConnectionString = myConnectionString.ConnectionString;


Building a Connection String at Runtime
It is common for applications to only know a subset of connection string information at configuration/deploy time (such as not knowing the name of the server to use). Since connection string information can be difficult or error prone to construct at runtime, the .Net Framework supports the ability to create appropriate connection strings via the DbConnectionStringBuilder types. Supporting runtime creation of an appropriate connection string can be done via:

Note: This example shows how to configure the server name at runtime. This is not the only available option with the MdxConnectionStringBuilder but the pattern remains the same regardless of what options are being provided at runtime.

1. Configure your application with the known values at runtime/deployment time
<connectionStrings>
  <add name="partialConnectString" 
    connectionString="Your Partial Connection String;"
    providerName="System.Data.MdxClient" />
</connectionStrings>


2. Acquire your configuration information at runtime. This can come from anywhere (e.g. an IoC container, UDDI, Active Directory, etc)
var myServerName = GetServerName(); // The logic for runtime location is specific to your application


3. Create a new MdxConnectionStringBuilder based on the partial connection string retrieved from the config file.
var builder = new MdxConnectionStringBuilder(myPartialConnectionString);
builder.ConnectTo = myServerName;


4. Construct the updated connection string and use!
var myUpdatedConnectionString = builder.ConnectionString; // Or call the ToString() method

Getting started

Please follow the steps below, to start using the MDX Client Adapter:
  1. Go to the Downloads tab and download the version appropriate for your runtime; (only .Net 3.5 and 4.0 are supported)
  2. Unpack the downloaded .zip file;
  3. Add the System.Data.MdxClient.dll to your projects that will use it by right-clicking on a project in the Visual Studio solution explorer and selecting 'Add Reference...'.
  4. Add the assembly to your start-up project and optional unit testing projects again by right-clicking on a project in the Visual Studio solution explorer and selecting 'Add Reference...'.
  5. Follow the patterns outlined in the Usage section

OR

Leverage NuGet (note only 4.0 edition is available over NuGet)
Install-Package MDXClientAdapter

Last edited Dec 24, 2011 at 4:04 PM by jimmyzimms, version 38