12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Configuration;
- using System.Data.SqlClient;
- using System.Web;
- namespace Bowin.Common.Linq.DB
- {
- public class SqlConnectionManager : DbConnectionManager
- {
- public static void InitConnections()
- {
- CloseConnections();
- foreach (ConnectionStringSettings connectionSetting in ((ConnectionStringsSection)(ConfigurationManager.GetSection("connectionStrings"))).ConnectionStrings)
- {
- SqlConnection db = new SqlConnection(connectionSetting.ConnectionString);
- try
- {
- db.Open();
- }
- catch
- {}
- AddConnection(connectionSetting.Name, db);
- }
- IsGlobalConnectionStarted = true;
- }
- public static new SqlConnection GetConnection(string contextKey)
- {
- if (IsGlobalConnectionStarted)
- {
- return (SqlConnection)DbConnectionManager.GetConnection(contextKey);
- }
- else
- {
- return null;
- }
- }
- }
- }
|