55using System . Reflection . Emit ;
66using NUnit . Framework ;
77using ServiceStack . Common . Tests ;
8+ using ServiceStack . OrmLite ;
89using ServiceStack . Reflection ;
910
1011namespace ServiceStack . Text . TestsConsole
1112{
1213 class Program
1314 {
14- static void Main ( string [ ] args )
15+ public static void Main ( string [ ] args )
1516 {
17+ PrintDumpColumnSchema ( ) ;
18+
1619 //var da = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName("dyn"), AssemblyBuilderAccess.Save);
1720
1821 //var dm = da.DefineDynamicModule("dyn_mod", "dyn.dll");
@@ -33,9 +36,9 @@ static void Main(string[] args)
3336 //dt.CreateType();
3437 //da.Save("dyn.dll");
3538
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();
3942
4043 Console . ReadLine ( ) ;
4144 }
@@ -58,5 +61,73 @@ public void Compare_interpolation_vs_string_Concat()
5861 public static object SimpleFormat ( string text ) => string . Format ( "Hi {0}" , text ) ;
5962
6063 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+ }
61132 }
62133}
0 commit comments