Skip to content
Igor Tkachev edited this page May 20, 2016 · 3 revisions

Home / Data / Linq

How to configure a data provider

BLToolkit Linq provider supports the following list of databases:

Data Provider Provider Name Namespace Vendor
AccessDataProvider Access System.Data.OleDb Microsoft
DB2DataProvider DB2 IBM.Data.DB2 IBM
InformixDataProvider Informix IBM.Data.Informix IBM
FdpDataProvider Fdp FirebirdSql.Data.FirebirdClient Firebird
MySqlDataProvider MySql MySql.Data.MySqlClient Sun Microsystems
OdpDataProvider ODP Oracle.DataAccess.Client Oracle
PostgreSQLProvider PostgreSQL Npgsql PostgreSQL.org
SqlCeDataProvider SqlCe System.Data.SqlServerCe Microsoft
SQLiteDataProvider SQLite System.Data.SQLite SQLite.org
SqlDataProvider Sql System.Data.SqlClient Microsoft (MS SQL 2005)
Sql2008DataProvider MsSql2008 System.Data.SqlClient Microsoft (MS SQL 2008)
SybaseDataProvider Sybase ASE Sybase.Data.AseClient Sybase

By default BLToolkit contains only data providers included in .NET Framework: MS SQL 2005, MS SQL 2008, and Microsoft Access. All other providers require additional components provided by the vendors.

To add support for those providers perform the following steps:

  • Download and install a 3rd party data provider.
  • Add a reference to the provider assembly in your project.
  • Add a corresponding C# file with a BLToolkit data provider implementation in your project. All providers are located in the Data\DataProvider folder of the BLToolkit project or in the same folder of the bltoolkit_bin archive if you use compiled version of the library.
  • Register the data provider using one of the following method:
using System;

using NUnit.Framework;

using BLToolkit.Data;
using BLToolkit.Data.DataProvider;

namespace HowTo.Data.DataProvider
{
    [TestFixture]
    public class AddDataProvider
    {
        const string connectionString = 
            "Data Source=DBHost;Port=5000;Database=BLToolkitData;Uid=sa";

        [Test]
        public void Test()
        {
            // 3rd party data provider registration.
            //
            DbManager.AddDataProvider(new SybaseDataProvider());

            // It can be configured by App.config.
            // We use this way for the demo purpose only.
            //
            DbManager.AddConnectionString(
                "Sybase",          // Provider name
                "Sybase",          // Configuration
                connectionString); // Connection string

            using (var db = new DbManager("Sybase"))
            {
            }
        }
    }
}

Or by using app.config file:

<?xml version="1.0"?>
<configuration>
    <configSections>
        <section name="bltoolkit" type="BLToolkit.Configuration.BLToolkitSection, BLToolkit.3"/>
    </configSections>
    <bltoolkit>
        <dataProviders>
            <add type="BLToolkit.Data.DataProvider.SybaseDataProvider, MyProjectName" />
        </dataProviders>
    </bltoolkit>
    <connectionStrings>
        <add name="Sybase" connectionString="Data Source=DBHost;Port=5000;Database=BLToolkitData;Uid=sa" providerName="Sybase.Data.AseClient"/>
    </connectionStrings>
</configuration>

See DbManager documentation for more details.

Clone this wiki locally