@@ -18,7 +18,8 @@ await Parser.Default.ParseArguments<Options>(args)
1818 var connString = $ "Host={ options . Host } ;Port={ options . Port } ;SSL Mode={ options . SslMode } ;" +
1919 $ "Username={ options . Username } ;Password={ options . Password } ;Database={ options . Database } ";
2020
21- await using var conn = GetConnection ( connString ) ;
21+ await using var dataSource = GetDataSource ( connString ) ;
22+ var conn = dataSource . OpenConnection ( ) ;
2223
2324 await DatabaseWorkloads . SystemQueryExample ( conn ) ;
2425 await DatabaseWorkloads . BasicConversationExample ( conn ) ;
@@ -32,12 +33,14 @@ await Parser.Default.ParseArguments<Options>(args)
3233 await dwt . ArrayPocoExample ( ) ;
3334 await dwt . GeoJsonTypesExample ( ) ;
3435 conn . Close ( ) ;
36+ dataSource . Dispose ( ) ;
3537 } ) ;
3638
3739 }
3840
39- public static NpgsqlConnection GetConnection ( string connString )
41+ public static NpgsqlDataSource GetDataSource ( string connString )
4042 {
43+ // It's just a testing rig. Do NOT log database credentials in production.
4144 Console . WriteLine ( $ "Connecting to database: { connString } \n ") ;
4245
4346 // Enable JSON POCO mapping and PostGIS/GeoJSON Type Plugin.
@@ -55,9 +58,7 @@ public static NpgsqlConnection GetConnection(string connString)
5558 // see also https://github.com/npgsql/npgsql/issues/2411.
5659 // dataSourceBuilder.UseGeoJson();
5760
58- var dataSource = dataSourceBuilder . Build ( ) ;
59- var conn = dataSource . OpenConnection ( ) ;
60- return conn ;
61+ return dataSourceBuilder . Build ( ) ;
6162 }
6263
6364 public class Options
0 commit comments