diff --git a/src/TestMongoDBConnection/Program.cs b/src/TestMongoDBConnection/Program.cs index af1e995..b7388ab 100644 --- a/src/TestMongoDBConnection/Program.cs +++ b/src/TestMongoDBConnection/Program.cs @@ -3,6 +3,7 @@ using System.Configuration; using System.Globalization; using System.IO; +using System.Linq; using System.Text; namespace TestMongoDBConnection @@ -28,7 +29,7 @@ private static void Main() } private static void TestConnectionString(string name, string connectionString) - { + { Log.AppendLine(); Log.AppendLine($"====== Test Date: {DateTime.Now.ToString(CultureInfo.InvariantCulture)} ======"); Log.AppendLine(); @@ -38,11 +39,13 @@ private static void TestConnectionString(string name, string connectionString) try { MongoClient client = new MongoClient(connectionString); - - var versionString = client.GetServer().BuildInfo.VersionString; + var mongoServer = client.GetServer(); + mongoServer.Connect(); + var buildInfos = mongoServer.Instances.Select(x => x.BuildInfo); + var versionStrings = buildInfos.Select(x => x.VersionString); Log.AppendLine(); - Log.AppendLine($"MongoDB version: {versionString}."); + Log.AppendLine($"MongoDB version: {string.Join(" | ", versionStrings)}."); Log.AppendLine("Connect is successful."); Log.AppendLine(); } @@ -61,7 +64,7 @@ private static void DumpLog(StringBuilder log) using (StreamWriter writer = new StreamWriter(fileName)) { writer.Write(log); - } + } } } } \ No newline at end of file