Enterprise Library Data Access Application Block  7.0-rc1
The Data Access Application Block abstracts the actual database you are using, and exposes a collection of methods that make it easy to access that database and to perform common tasks.
Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory Class Reference

Contains factory methods for creating Database objects. More...

Static Public Member Functions

static Database CreateDatabase ()
 Creates the default Database object More...
 
static Database CreateDatabase (string name)
 Creates the Database object with the specified name. More...
 
static void SetDatabaseProviderFactory (DatabaseProviderFactory factory, bool throwIfSet=true)
 Sets the provider factory for the static DatabaseFactory. More...
 
static void SetDatabases (Func< Database > createDefaultDatabase, Func< string, Database > createNamedDatabase, bool throwIfSet=true)
 Sets the database mappings. More...
 
static void ClearDatabaseProviderFactory ()
 Clears the provider factory for the static DatabaseFactory. More...
 

Detailed Description

Contains factory methods for creating Database objects.

Member Function Documentation

◆ ClearDatabaseProviderFactory()

static void Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.ClearDatabaseProviderFactory ( )
static

Clears the provider factory for the static DatabaseFactory.

◆ CreateDatabase() [1/2]

static Database Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase ( )
static

Creates the default Database object

Database dbSvc = DatabaseFactory.CreateDatabase();
Returns
The default database
Exceptions
System.Configuration.ConfigurationErrorsExceptionThe configuration information cannot be read.
System.InvalidOperationExceptionThe database factory has not been initialized or some configuration information is missing.

◆ CreateDatabase() [2/2]

static Database Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase ( string  name)
static

Creates the Database object with the specified name.

Database dbSvc = DatabaseFactory.CreateDatabase("SQL_Customers");
Parameters
nameThe configuration key for database service
Returns
The database with the specified name
Exceptions
System.Configuration.ConfigurationErrorsExceptionThe configuration information cannot be read.
System.InvalidOperationExceptionThe database factory has not been initialized or some configuration information is missing.

◆ SetDatabaseProviderFactory()

static void Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.SetDatabaseProviderFactory ( DatabaseProviderFactory  factory,
bool  throwIfSet = true 
)
static

Sets the provider factory for the static DatabaseFactory.

Parameters
factoryThe provider factory.
throwIfSettrue to thrown an exception if the factory is already set; otherwise, false. Defaults to true.
Exceptions
InvalidOperationExceptionThe factory is already set and throwIfSet is true.

◆ SetDatabases()

static void Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.SetDatabases ( Func< Database createDefaultDatabase,
Func< string, Database createNamedDatabase,
bool  throwIfSet = true 
)
static

Sets the database mappings.

Parameters
createDefaultDatabaseA method that returns the default database.
createNamedDatabaseA method that returns a database for the specified name.
throwIfSettrue to thrown an exception if the factory is already set; otherwise, false. Defaults to true.
Exceptions
InvalidOperationExceptionThe factory is already set and throwIfSet is true.

The documentation for this class was generated from the following file: