public static string GetConnectionString <T>(string connectionName) where T : class { connectionName = ConfigHelper.GetValue(connectionName, connectionName); string format = "metadata=res://*/Entity.{0}.csdl|res://*/Entity.{0}.ssdl|res://*/Entity.{0}.msl;provider=MySql.Data.MySqlClient;provider connection string=\"{1}\""; string str2 = typeof(T).Name.Replace("Entities", "Model"); return(string.Format(format, str2, EncryptConnectionHelper.ConnectionString(connectionName))); }
public static string GetConnectionString(string connectionKeyOrConnectionString) { if (string.IsNullOrWhiteSpace(connectionKeyOrConnectionString)) { throw new ArgumentNullException(connectionKeyOrConnectionString, "参数connectionKeyOrConnectionString不能为空值"); } string str = ""; if (connectionKeyOrConnectionString.Split(new char[] { '=' }).Count <string>() > 2) { str = connectionKeyOrConnectionString; } else { str = EncryptConnectionHelper.ConnectionString(connectionKeyOrConnectionString); } if (string.IsNullOrWhiteSpace(str)) { throw new ArgumentNullException("对不起你设置的连接:" + connectionKeyOrConnectionString + "获取不到相关值"); } return(str); }