5
5
using System . Reflection . Emit ;
6
6
using NUnit . Framework ;
7
7
using ServiceStack . Common . Tests ;
8
+ using ServiceStack . OrmLite ;
8
9
using ServiceStack . Reflection ;
9
10
10
11
namespace ServiceStack . Text . TestsConsole
11
12
{
12
13
class Program
13
14
{
14
- static void Main ( string [ ] args )
15
+ public static void Main ( string [ ] args )
15
16
{
17
+ PrintDumpColumnSchema ( ) ;
18
+
16
19
//var da = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName("dyn"), AssemblyBuilderAccess.Save);
17
20
18
21
//var dm = da.DefineDynamicModule("dyn_mod", "dyn.dll");
@@ -33,9 +36,9 @@ static void Main(string[] args)
33
36
//dt.CreateType();
34
37
//da.Save("dyn.dll");
35
38
36
- new StringConcatPerfTests {
37
- MultipleIterations = new [ ] { 1000 , 10000 , 100000 , 1000000 , 10000000 }
38
- } . Compare_interpolation_vs_string_Concat ( ) ;
39
+ // new StringConcatPerfTests {
40
+ // MultipleIterations = new[] { 1000, 10000, 100000, 1000000, 10000000 }
41
+ // }.Compare_interpolation_vs_string_Concat();
39
42
40
43
Console . ReadLine ( ) ;
41
44
}
@@ -58,5 +61,73 @@ public void Compare_interpolation_vs_string_Concat()
58
61
public static object SimpleFormat ( string text ) => string . Format ( "Hi {0}" , text ) ;
59
62
60
63
public static object SimpleConcat ( string text ) => "Hi " + text ;
64
+
65
+ public static void PrintDumpColumnSchema ( )
66
+ {
67
+ var dbFactory = new OrmLiteConnectionFactory ( ":memory:" ,
68
+ SqliteDialect . Provider ) ;
69
+
70
+ using var db = dbFactory . Open ( ) ;
71
+ db . CreateTableIfNotExists < Person > ( ) ;
72
+
73
+ ColumnSchema [ ] columnSchemas = db . GetTableColumns < Person > ( ) ;
74
+
75
+ columnSchemas . Each ( x => x . ToString ( ) . Print ( ) ) ;
76
+ columnSchemas . Each ( x => x . PrintDump ( ) ) ;
77
+ }
78
+
79
+ public class Person
80
+ {
81
+ public static Person [ ] Rockstars = {
82
+ new ( 1 , "Jimi" , "Hendrix" , 27 ) ,
83
+ new ( 2 , "Janis" , "Joplin" , 27 ) ,
84
+ new ( 3 , "Jim" , "Morrisson" , 27 ) ,
85
+ new ( 4 , "Kurt" , "Cobain" , 27 ) ,
86
+ new ( 5 , "Elvis" , "Presley" , 42 ) ,
87
+ new ( 6 , "Michael" , "Jackson" , 50 ) ,
88
+ } ;
89
+
90
+ public int Id { get ; set ; }
91
+ public string FirstName { get ; set ; }
92
+ public string LastName { get ; set ; }
93
+ public int Age { get ; set ; }
94
+
95
+ public Person ( ) { }
96
+ public Person ( int id , string firstName , string lastName , int age )
97
+ {
98
+ Id = id ;
99
+ FirstName = firstName ;
100
+ LastName = lastName ;
101
+ Age = age ;
102
+ }
103
+
104
+ protected bool Equals ( Person other )
105
+ {
106
+ return Id == other . Id &&
107
+ string . Equals ( FirstName , other . FirstName ) &&
108
+ string . Equals ( LastName , other . LastName ) &&
109
+ Age == other . Age ;
110
+ }
111
+
112
+ public override bool Equals ( object obj )
113
+ {
114
+ if ( ReferenceEquals ( null , obj ) ) return false ;
115
+ if ( ReferenceEquals ( this , obj ) ) return true ;
116
+ if ( obj . GetType ( ) != this . GetType ( ) ) return false ;
117
+ return Equals ( ( Person ) obj ) ;
118
+ }
119
+
120
+ public override int GetHashCode ( )
121
+ {
122
+ unchecked
123
+ {
124
+ var hashCode = Id ;
125
+ hashCode = ( hashCode * 397 ) ^ ( FirstName != null ? FirstName . GetHashCode ( ) : 0 ) ;
126
+ hashCode = ( hashCode * 397 ) ^ ( LastName != null ? LastName . GetHashCode ( ) : 0 ) ;
127
+ hashCode = ( hashCode * 397 ) ^ Age ;
128
+ return hashCode ;
129
+ }
130
+ }
131
+ }
61
132
}
62
133
}
0 commit comments