You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Data.Common;
|
|
using NetLibrary.Common.Configuration;
|
|
|
|
namespace NetLibrary.Data
|
|
{
|
|
public static class DatabaseFactory
|
|
{
|
|
public static Database CreateDatabase()
|
|
{
|
|
Database db = null;
|
|
if (DataCache.ConfigCache.ContainsKey("ConnectionString") == false)
|
|
{
|
|
ConfigurationSourceSection.GetConnection("ConnectionString");
|
|
}
|
|
DbProviderFactory Factory = DbProviderFactories.GetFactory(DataCache.ConfigCache["ConnectionString"].Namespace);
|
|
string ConnectionString = DataCache.ConfigCache["ConnectionString"].Value;
|
|
db = new Database(ConnectionString, Factory);
|
|
return db;
|
|
}
|
|
|
|
public static Database CreateDatabase(string name)
|
|
{
|
|
Database db = null;
|
|
if (DataCache.ConfigCache.ContainsKey(name) == false)
|
|
{
|
|
ConfigurationSourceSection.GetConnection(name);
|
|
}
|
|
DbProviderFactory Factory = DbProviderFactories.GetFactory(DataCache.ConfigCache[name].Namespace);
|
|
string ConnectionString = DataCache.ConfigCache[name].Value;
|
|
db = new Database(ConnectionString, Factory);
|
|
return db;
|
|
}
|
|
}
|
|
} |