/// <summary> /// 获取写入用数据库连接串,来自配置 AOA.Common.Utility.CustomConfig.ConnectionSection /// </summary> /// <param name="connectionName">连接串名称</param> /// <returns>连接串(写入用)</returns> public static string GetWriteConnectionString(string connectionName) { ConnectionElement connectionElement = CustomConfigHelper.Connections[connectionName]; if (connectionElement != null) { return(string.IsNullOrEmpty(connectionElement.WriteString) ? connectionElement.ConnString : connectionElement.ReadString); } else { return(GetConnectionString(connectionName)); } }
/// <summary> /// 获取默认数据库连接串,来自配置 AOA.Common.Utility.CustomConfig.ConnectionSection /// </summary> /// <param name="connectionName">连接串名称</param> /// <returns>连接串(读取用)</returns> public static string GetDefaultConnectionString(string connectionName) { ConnectionElement connectionElement = CustomConfigHelper.Connections[connectionName]; if (connectionElement != null) { return(connectionElement.ConnString); } else { return(GetConnectionString(connectionName)); } }
/// <summary> /// 通过名称取得指定的连接串节点 /// </summary> /// <param name="connectionName">连接串名称</param> /// <returns>连接串节点</returns> public ConnectionElement GetByName(string connectionName) { ConnectionElement connectionElement = null; foreach (ConnectionElement element in this) { if (element.ConnName.ToLower() == connectionName.ToLower()) { connectionElement = element; break; } } return(connectionElement); }
/// <summary> /// 构建函数 /// </summary> public ConnectionSection() { element = new ConnectionElement(); }
/// <summary> /// 返回一个节点的Key /// </summary> /// <param name="element">需要返回Key的 <see cref="T:ConfigurationElement"/> 节点</param> /// <returns>一个包含 <see cref="T:ConfigurationElement"/> 节点Key的 <see cref="T:Object"/></returns> protected override object GetElementKey(ConfigurationElement element) { ConnectionElement ce = (ConnectionElement)element; return(ce.ConnName); }