| using System; | 
| using System.Collections.Generic; | 
| using System.Configuration; | 
| using System.Linq; | 
| using System.Web; | 
|   | 
| namespace WebAPI.Dapper | 
| { | 
|     public class SqlPools | 
|     { | 
|         public SqlPools() | 
|         { | 
|             SecConnStr(); | 
|         } | 
|         static Dictionary<string, string> sqlDic = new Dictionary<string, string>(); | 
|         /// <summary> | 
|         /// 将配置文件夹中的数据库链接全部遍历至字典 | 
|         /// </summary> | 
|         private void SecConnStr() | 
|         { | 
|             ConnectionStringSettingsCollection seetings = ConfigurationManager.ConnectionStrings;//获取配置文件connectionstring所有节点 | 
|             for (int i = 0; i < seetings.Count; i++) | 
|             { | 
|                 sqlDic.Add(seetings[i].Name, seetings[i].ConnectionString);//存入字典 | 
|             } | 
|         } | 
|         /// <summary> | 
|         /// sqlhelper实例化 | 
|         /// </summary> | 
|         /// <param name="dbName"></param> | 
|         /// <returns></returns> | 
|         public static SqlHelper GetInstance(string dbName) | 
|         { | 
|             return new SqlHelper(sqlDic[dbName]);//从字典取出数据库链接字符串 | 
|         } | 
|     } | 
| } |