@@ -361,14 +361,14 @@ public async Task<List<GetAuthorsByIdsAndNamesRow>> GetAuthorsByIdsAndNames(GetA
361361 private const string CreateBookSql = "INSERT INTO books (name, author_id) VALUES (@name, @author_id) RETURNING id" ;
362362 public class CreateBookRow
363363 {
364- public required long Id { get ; init ; }
364+ public required Guid Id { get ; init ; }
365365 } ;
366366 public class CreateBookArgs
367367 {
368368 public required string Name { get ; init ; }
369369 public required long AuthorId { get ; init ; }
370370 } ;
371- public async Task < long > CreateBook ( CreateBookArgs args )
371+ public async Task < Guid > CreateBook ( CreateBookArgs args )
372372 {
373373 var queryParams = new Dictionary < string , object ? > ( ) ;
374374 queryParams . Add ( "name" , args . Name ) ;
@@ -377,7 +377,7 @@ public async Task<long> CreateBook(CreateBookArgs args)
377377 {
378378 using ( var connection = new NpgsqlConnection ( ConnectionString ) )
379379 {
380- return await connection . QuerySingleAsync < long > ( CreateBookSql , queryParams ) ;
380+ return await connection . QuerySingleAsync < Guid > ( CreateBookSql , queryParams ) ;
381381 }
382382 }
383383
@@ -386,7 +386,7 @@ public async Task<long> CreateBook(CreateBookArgs args)
386386 throw new System . InvalidOperationException ( "Transaction is provided, but its connection is null." ) ;
387387 }
388388
389- return await this . Transaction . Connection . QuerySingleAsync < long > ( CreateBookSql , queryParams , transaction : this . Transaction ) ;
389+ return await this . Transaction . Connection . QuerySingleAsync < Guid > ( CreateBookSql , queryParams , transaction : this . Transaction ) ;
390390 }
391391
392392 private const string ListAllAuthorsBooksSql = "SELECT authors . id , authors . name, authors . bio, books . id, books . name, books . author_id, books . description FROM authors INNER JOIN books ON authors . id = books . author_id ORDER BY authors . name " ;
@@ -407,7 +407,7 @@ public async Task<List<ListAllAuthorsBooksRow>> ListAllAuthorsBooks()
407407 {
408408 var result = new List < ListAllAuthorsBooksRow > ( ) ;
409409 while ( await reader . ReadAsync ( ) )
410- result . Add ( new ListAllAuthorsBooksRow { Author = new Author { Id = reader . GetInt64 ( 0 ) , Name = reader . GetString ( 1 ) , Bio = reader . IsDBNull ( 2 ) ? null : reader . GetString ( 2 ) } , Book = new Book { Id = reader . GetInt64 ( 3 ) , Name = reader . GetString ( 4 ) , AuthorId = reader . GetInt64 ( 5 ) , Description = reader . IsDBNull ( 6 ) ? null : reader . GetString ( 6 ) } } ) ;
410+ result . Add ( new ListAllAuthorsBooksRow { Author = new Author { Id = reader . GetInt64 ( 0 ) , Name = reader . GetString ( 1 ) , Bio = reader . IsDBNull ( 2 ) ? null : reader . GetString ( 2 ) } , Book = new Book { Id = reader . GetFieldValue < Guid > ( 3 ) , Name = reader . GetString ( 4 ) , AuthorId = reader . GetInt64 ( 5 ) , Description = reader . IsDBNull ( 6 ) ? null : reader . GetString ( 6 ) } } ) ;
411411 return result ;
412412 }
413413 }
@@ -424,7 +424,7 @@ public async Task<List<ListAllAuthorsBooksRow>> ListAllAuthorsBooks()
424424 {
425425 var result = new List < ListAllAuthorsBooksRow > ( ) ;
426426 while ( await reader . ReadAsync ( ) )
427- result . Add ( new ListAllAuthorsBooksRow { Author = new Author { Id = reader . GetInt64 ( 0 ) , Name = reader . GetString ( 1 ) , Bio = reader . IsDBNull ( 2 ) ? null : reader . GetString ( 2 ) } , Book = new Book { Id = reader . GetInt64 ( 3 ) , Name = reader . GetString ( 4 ) , AuthorId = reader . GetInt64 ( 5 ) , Description = reader . IsDBNull ( 6 ) ? null : reader . GetString ( 6 ) } } ) ;
427+ result . Add ( new ListAllAuthorsBooksRow { Author = new Author { Id = reader . GetInt64 ( 0 ) , Name = reader . GetString ( 1 ) , Bio = reader . IsDBNull ( 2 ) ? null : reader . GetString ( 2 ) } , Book = new Book { Id = reader . GetFieldValue < Guid > ( 3 ) , Name = reader . GetString ( 4 ) , AuthorId = reader . GetInt64 ( 5 ) , Description = reader . IsDBNull ( 6 ) ? null : reader . GetString ( 6 ) } } ) ;
428428 return result ;
429429 }
430430 }
@@ -496,7 +496,7 @@ public async Task<List<GetAuthorsByBookNameRow>> GetAuthorsByBookName(GetAuthors
496496 {
497497 var result = new List < GetAuthorsByBookNameRow > ( ) ;
498498 while ( await reader . ReadAsync ( ) )
499- result . Add ( new GetAuthorsByBookNameRow { Id = reader . GetInt64 ( 0 ) , Name = reader . GetString ( 1 ) , Bio = reader . IsDBNull ( 2 ) ? null : reader . GetString ( 2 ) , Book = new Book { Id = reader . GetInt64 ( 3 ) , Name = reader . GetString ( 4 ) , AuthorId = reader . GetInt64 ( 5 ) , Description = reader . IsDBNull ( 6 ) ? null : reader . GetString ( 6 ) } } ) ;
499+ result . Add ( new GetAuthorsByBookNameRow { Id = reader . GetInt64 ( 0 ) , Name = reader . GetString ( 1 ) , Bio = reader . IsDBNull ( 2 ) ? null : reader . GetString ( 2 ) , Book = new Book { Id = reader . GetFieldValue < Guid > ( 3 ) , Name = reader . GetString ( 4 ) , AuthorId = reader . GetInt64 ( 5 ) , Description = reader . IsDBNull ( 6 ) ? null : reader . GetString ( 6 ) } } ) ;
500500 return result ;
501501 }
502502 }
@@ -514,7 +514,7 @@ public async Task<List<GetAuthorsByBookNameRow>> GetAuthorsByBookName(GetAuthors
514514 {
515515 var result = new List < GetAuthorsByBookNameRow > ( ) ;
516516 while ( await reader . ReadAsync ( ) )
517- result . Add ( new GetAuthorsByBookNameRow { Id = reader . GetInt64 ( 0 ) , Name = reader . GetString ( 1 ) , Bio = reader . IsDBNull ( 2 ) ? null : reader . GetString ( 2 ) , Book = new Book { Id = reader . GetInt64 ( 3 ) , Name = reader . GetString ( 4 ) , AuthorId = reader . GetInt64 ( 5 ) , Description = reader . IsDBNull ( 6 ) ? null : reader . GetString ( 6 ) } } ) ;
517+ result . Add ( new GetAuthorsByBookNameRow { Id = reader . GetInt64 ( 0 ) , Name = reader . GetString ( 1 ) , Bio = reader . IsDBNull ( 2 ) ? null : reader . GetString ( 2 ) , Book = new Book { Id = reader . GetFieldValue < Guid > ( 3 ) , Name = reader . GetString ( 4 ) , AuthorId = reader . GetInt64 ( 5 ) , Description = reader . IsDBNull ( 6 ) ? null : reader . GetString ( 6 ) } } ) ;
518518 return result ;
519519 }
520520 }
0 commit comments