|
1 |
| -using System; |
2 | 1 | using System.Collections.Generic;
|
3 | 2 | using System.Threading.Tasks;
|
4 | 3 | using Dapper;
|
5 | 4 | using Npgsql;
|
6 | 5 |
|
7 |
| -namespace PlatformBenchmarks |
| 6 | +namespace PlatformBenchmarks; |
| 7 | + |
| 8 | +public sealed class DapperDb |
8 | 9 | {
|
9 |
| - public sealed class DapperDb |
10 |
| - { |
11 |
| - private readonly string _connectionString; |
| 10 | + private readonly string _connectionString; |
12 | 11 |
|
13 |
| - public DapperDb(AppSettings appSettings) |
14 |
| - => _connectionString = appSettings.ConnectionString; |
| 12 | + public DapperDb(AppSettings appSettings) |
| 13 | + => _connectionString = appSettings.ConnectionString; |
15 | 14 |
|
16 |
| - public async Task<List<FortuneUtf16>> LoadFortunesRows() |
17 |
| - { |
18 |
| - List<FortuneUtf16> result; |
| 15 | + public async Task<List<FortuneUtf16>> LoadFortunesRows() |
| 16 | + { |
| 17 | + List<FortuneUtf16> result; |
19 | 18 |
|
20 |
| - using (var db = new NpgsqlConnection(_connectionString)) |
21 |
| - { |
22 |
| - // Note: don't need to open connection if only doing one thing; let dapper do it |
23 |
| - result = (await db.QueryAsync<FortuneUtf16>("SELECT id, message FROM fortune")).AsList(); |
24 |
| - } |
| 19 | + using (var db = new NpgsqlConnection(_connectionString)) |
| 20 | + { |
| 21 | + // Note: don't need to open connection if only doing one thing; let dapper do it |
| 22 | + result = (await db.QueryAsync<FortuneUtf16>("SELECT id, message FROM fortune")).AsList(); |
| 23 | + } |
25 | 24 |
|
26 |
| - result.Add(new FortuneUtf16(id: 0, message: "Additional fortune added at request time." )); |
27 |
| - result.Sort(); |
| 25 | + result.Add(new FortuneUtf16(id: 0, message: "Additional fortune added at request time." )); |
| 26 | + result.Sort(); |
28 | 27 |
|
29 |
| - return result; |
30 |
| - } |
| 28 | + return result; |
31 | 29 | }
|
32 | 30 | }
|
0 commit comments