4
4
// ReSharper disable InconsistentNaming
5
5
using System . Collections . Generic ;
6
6
using System . Threading . Tasks ;
7
+ using System ;
7
8
using MySqlConnector ;
8
9
9
10
namespace MySqlConnectorExampleGen ;
10
11
public class QuerySql ( string connectionString )
11
12
{
12
- private const string GetAuthorSql = "SELECT id, name, bio FROM authors WHERE name = @name LIMIT 1" ;
13
- public readonly record struct GetAuthorRow ( long Id , string Name , string ? Bio ) ;
13
+ private const string GetAuthorSql = "SELECT id, name, bio, created FROM authors WHERE name = @name LIMIT 1" ;
14
+ public readonly record struct GetAuthorRow ( long Id , string Name , string ? Bio , DateTime Created ) ;
14
15
public readonly record struct GetAuthorArgs ( string Name ) ;
15
16
public async Task < GetAuthorRow ? > GetAuthor ( GetAuthorArgs args )
16
17
{
@@ -26,16 +27,17 @@ public class QuerySql(string connectionString)
26
27
{
27
28
Id = reader . GetInt64 ( 0 ) ,
28
29
Name = reader . GetString ( 1 ) ,
29
- Bio = reader . IsDBNull ( 2 ) ? null : reader . GetString ( 2 )
30
+ Bio = reader . IsDBNull ( 2 ) ? null : reader . GetString ( 2 ) ,
31
+ Created = reader . GetDateTime ( 3 )
30
32
} ;
31
33
}
32
34
33
35
return null ;
34
36
}
35
37
}
36
38
37
- private const string ListAuthorsSql = "SELECT id, name, bio FROM authors ORDER BY name" ;
38
- public readonly record struct ListAuthorsRow ( long Id , string Name , string ? Bio ) ;
39
+ private const string ListAuthorsSql = "SELECT id, name, bio, created FROM authors ORDER BY name" ;
40
+ public readonly record struct ListAuthorsRow ( long Id , string Name , string ? Bio , DateTime Created ) ;
39
41
public async Task < List < ListAuthorsRow > > ListAuthors ( )
40
42
{
41
43
{
@@ -46,7 +48,7 @@ public async Task<List<ListAuthorsRow>> ListAuthors()
46
48
var result = new List < ListAuthorsRow > ( ) ;
47
49
while ( await reader . ReadAsync ( ) )
48
50
{
49
- result . Add ( new ListAuthorsRow { Id = reader . GetInt64 ( 0 ) , Name = reader . GetString ( 1 ) , Bio = reader . IsDBNull ( 2 ) ? null : reader . GetString ( 2 ) } ) ;
51
+ result . Add ( new ListAuthorsRow { Id = reader . GetInt64 ( 0 ) , Name = reader . GetString ( 1 ) , Bio = reader . IsDBNull ( 2 ) ? null : reader . GetString ( 2 ) , Created = reader . GetDateTime ( 3 ) } ) ;
50
52
}
51
53
52
54
return result ;
@@ -121,7 +123,7 @@ public async Task TruncateAuthors()
121
123
}
122
124
123
125
private const string TestSql = "SELECT c_bit, c_tinyint, c_bool, c_boolean, c_smallint, c_mediumint, c_int, c_integer, c_bigint, c_serial, c_decimal, c_dec, c_numeric, c_fixed, c_float, c_double, c_double_precision, c_date, c_time, c_datetime, c_timestamp, c_year, c_char, c_nchar, c_national_char, c_varchar, c_binary, c_varbinary, c_tinyblob, c_tinytext, c_blob, c_text, c_mediumblob, c_mediumtext, c_longblob, c_longtext, c_json FROM node_mysql_types LIMIT 1" ;
124
- public readonly record struct TestRow ( byte [ ] ? C_bit , int ? C_tinyint , int ? C_bool , int ? C_boolean , int ? C_smallint , int ? C_mediumint , int ? C_int , int ? C_integer , long ? C_bigint , long C_serial , string ? C_decimal , string ? C_dec , string ? C_numeric , string ? C_fixed , double ? C_float , double ? C_double , double ? C_double_precision , string ? C_date , string ? C_time , string ? C_datetime , string ? C_timestamp , int ? C_year , string ? C_char , string ? C_nchar , string ? C_national_char , string ? C_varchar , byte [ ] ? C_binary , byte [ ] ? C_varbinary , byte [ ] ? C_tinyblob , string ? C_tinytext , byte [ ] ? C_blob , string ? C_text , byte [ ] ? C_mediumblob , string ? C_mediumtext , byte [ ] ? C_longblob , string ? C_longtext , object ? C_json ) ;
126
+ public readonly record struct TestRow ( byte [ ] ? C_bit , int ? C_tinyint , int ? C_bool , int ? C_boolean , int ? C_smallint , int ? C_mediumint , int ? C_int , int ? C_integer , long ? C_bigint , long C_serial , string ? C_decimal , string ? C_dec , string ? C_numeric , string ? C_fixed , double ? C_float , double ? C_double , double ? C_double_precision , DateTime ? C_date , string ? C_time , DateTime ? C_datetime , DateTime ? C_timestamp , int ? C_year , string ? C_char , string ? C_nchar , string ? C_national_char , string ? C_varchar , byte [ ] ? C_binary , byte [ ] ? C_varbinary , byte [ ] ? C_tinyblob , string ? C_tinytext , byte [ ] ? C_blob , string ? C_text , byte [ ] ? C_mediumblob , string ? C_mediumtext , byte [ ] ? C_longblob , string ? C_longtext , object ? C_json ) ;
125
127
public async Task < TestRow ? > Test ( )
126
128
{
127
129
{
@@ -150,10 +152,10 @@ public async Task TruncateAuthors()
150
152
C_float = reader . IsDBNull ( 14 ) ? null : reader . GetDouble ( 14 ) ,
151
153
C_double = reader . IsDBNull ( 15 ) ? null : reader . GetDouble ( 15 ) ,
152
154
C_double_precision = reader . IsDBNull ( 16 ) ? null : reader . GetDouble ( 16 ) ,
153
- C_date = reader . IsDBNull ( 17 ) ? null : reader . GetString ( 17 ) ,
155
+ C_date = reader . IsDBNull ( 17 ) ? null : reader . GetDateTime ( 17 ) ,
154
156
C_time = reader . IsDBNull ( 18 ) ? null : reader . GetString ( 18 ) ,
155
- C_datetime = reader . IsDBNull ( 19 ) ? null : reader . GetString ( 19 ) ,
156
- C_timestamp = reader . IsDBNull ( 20 ) ? null : reader . GetString ( 20 ) ,
157
+ C_datetime = reader . IsDBNull ( 19 ) ? null : reader . GetDateTime ( 19 ) ,
158
+ C_timestamp = reader . IsDBNull ( 20 ) ? null : reader . GetDateTime ( 20 ) ,
157
159
C_year = reader . IsDBNull ( 21 ) ? null : reader . GetInt32 ( 21 ) ,
158
160
C_char = reader . IsDBNull ( 22 ) ? null : reader . GetString ( 22 ) ,
159
161
C_nchar = reader . IsDBNull ( 23 ) ? null : reader . GetString ( 23 ) ,
0 commit comments