1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using cuidian.Common;
- using System;
- using System.Collections.Generic;
- using System.Data.SqlClient;
- using System.Linq;
- using System.Text;
- namespace cuidian.Sql
- {
- public class ConnectionUtils
- {
- private static ConnectionUtils __instance = new ConnectionUtils();
- private Dictionary<string, SqlConnection> __maps = new Dictionary<string, SqlConnection>();
- private ConnectionUtils()
- { }
- public static ConnectionUtils Instance
- {
- get { return __instance; }
- }
- public SqlConnection GetConnection()
- {
- return GetConnection(AppSeting.Instance.GetValue("Traget"));
- }
- public SqlConnection GetConnection(string key)
- {
- SqlConnection con;
- if (__maps.ContainsKey(key)) return __maps[key];
- con = new SqlConnection(AppSeting.Instance.GetConnectstr(key));
- //__maps.Add(key, con);
- __maps[key] = con;
- return con;
- }
- }
- }
|