0
初めてポストグルデータベースへの接続がタイムアウトすると、プログラムは実行時に2番目の接続を試みます。MVC5を使用して2つのポストグル接続文字列を切り替える方法
2つの接続文字列は、2つの異なるサーバーに接続します。ここで
初めてポストグルデータベースへの接続がタイムアウトすると、プログラムは実行時に2番目の接続を試みます。MVC5を使用して2つのポストグル接続文字列を切り替える方法
2つの接続文字列は、2つの異なるサーバーに接続します。ここで
は私の質問を解決する:
public class DbConnection
{
private static string _connectionString;
private static string GetConnectionString
{
get
{
return _connectionString ?? (_connectionString = SelectConnectionString());
}
}
private static string SelectConnectionString()
{
try
{
Database db = new Database("Your connection string");
db.OpenSharedConnection();//this is petapoco ORM function
db.CloseSharedConnection();
return "Your connnection string name";
}
catch
{
return "LocalConnection";
}
}
public static Database TestDbConnection()
{
return new Database(GetConnectionString);
}
}
私は本当にそのようなことをやっての値が表示されません。私の上司と明確にしたように、私のプロジェクトの最終的な解決策はこれより簡単で、実際には別の質問です。最終的な解決策は基本的にWeb.Release.configファイル内に接続文字列を設定することです。 – oopsdazie