1+ // auto-generated by sqlc - do not edit
2+ using System ;
3+ using System . Collections . Generic ;
4+ using System . Linq ;
5+
6+ namespace QuickStartMySqlDalGen ;
7+ public readonly record struct Author ( long Id , string Name , string ? Bio ) ;
8+ public readonly record struct Book ( long Id , string Name , long AuthorId , string ? Description ) ;
9+ public readonly record struct ExtendedBio ( string ? AuthorName , string ? Name , BiosBioType ? BioType , HashSet < BiosAuthorType > ? AuthorType ) ;
10+ public enum BiosBioType
11+ {
12+ Invalid = 0 , // reserved for invalid enum value
13+ Autobiography = 1 ,
14+ Biography = 2 ,
15+ Memoir = 3
16+ }
17+
18+ public static class BiosBioTypeExtensions
19+ {
20+ private static readonly Dictionary < string , BiosBioType > StringToEnum = new Dictionary < string , BiosBioType > ( )
21+ {
22+ [ string . Empty ] = BiosBioType . Invalid ,
23+ [ "Autobiography" ] = BiosBioType . Autobiography ,
24+ [ "Biography" ] = BiosBioType . Biography ,
25+ [ "Memoir" ] = BiosBioType . Memoir
26+ } ;
27+ public static BiosBioType ToBiosBioType ( this string me )
28+ {
29+ return StringToEnum [ me ] ;
30+ }
31+
32+ public static HashSet < BiosBioType > ToBiosBioTypeSet ( this string me )
33+ {
34+ return new HashSet < BiosBioType > ( me . Split ( ',' ) . ToList ( ) . Select ( v => StringToEnum [ v ] ) ) ;
35+ }
36+ }
37+
38+ public enum BiosAuthorType
39+ {
40+ Invalid = 0 , // reserved for invalid enum value
41+ Author = 1 ,
42+ Editor = 2 ,
43+ Translator = 3
44+ }
45+
46+ public static class BiosAuthorTypeExtensions
47+ {
48+ private static readonly Dictionary < string , BiosAuthorType > StringToEnum = new Dictionary < string , BiosAuthorType > ( )
49+ {
50+ [ string . Empty ] = BiosAuthorType . Invalid ,
51+ [ "Author" ] = BiosAuthorType . Author ,
52+ [ "Editor" ] = BiosAuthorType . Editor ,
53+ [ "Translator" ] = BiosAuthorType . Translator
54+ } ;
55+ public static BiosAuthorType ToBiosAuthorType ( this string me )
56+ {
57+ return StringToEnum [ me ] ;
58+ }
59+
60+ public static HashSet < BiosAuthorType > ToBiosAuthorTypeSet ( this string me )
61+ {
62+ return new HashSet < BiosAuthorType > ( me . Split ( ',' ) . ToList ( ) . Select ( v => StringToEnum [ v ] ) ) ;
63+ }
64+ }
0 commit comments