@@ -6,10 +6,11 @@ namespace SharpEngine.SQLite;
66/// <summary>
77/// Sqlite Data Table
88/// </summary>
9- public class SQLiteDataTable < T > : IDataTable where T : new ( )
9+ public class SQLiteDataTable < T > : IDataTable
10+ where T : new ( )
1011{
1112 private List < dynamic > Objects { get ; }
12-
13+
1314 /// <summary>
1415 /// Create Data Table from SQLite
1516 /// </summary>
@@ -19,33 +20,37 @@ namespace SharpEngine.SQLite;
1920 public SQLiteDataTable ( string dbFile , string version = "3" )
2021 {
2122 Objects = new List < dynamic > ( ) ;
22-
23- var connection = new SQLiteConnection ( $ "Data Source={ dbFile } ;Version={ version } ;New=True;Compress=True;") ;
24-
23+
24+ var connection = new SQLiteConnection (
25+ $ "Data Source={ dbFile } ;Version={ version } ;New=True;Compress=True;"
26+ ) ;
27+
2528 connection . Open ( ) ;
26-
29+
2730 var cmd = connection . CreateCommand ( ) ;
2831 cmd . CommandText = $ "SELECT * FROM { typeof ( T ) . Name } ;";
2932 var reader = cmd . ExecuteReader ( ) ;
3033 while ( reader . Read ( ) )
3134 {
3235 var obj = new T ( ) ;
33-
36+
3437 var index = 0 ;
3538 foreach ( var property in typeof ( T ) . GetProperties ( ) )
3639 {
37- if ( reader . IsDBNull ( index ) )
40+ if ( reader . IsDBNull ( index ) )
3841 property . SetValue ( obj , null ) ;
39- else if ( property . PropertyType == typeof ( string ) )
42+ else if ( property . PropertyType == typeof ( string ) )
4043 property . SetValue ( obj , reader . GetString ( index ) ) ;
41- else if ( property . PropertyType == typeof ( int ) )
44+ else if ( property . PropertyType == typeof ( int ) )
4245 property . SetValue ( obj , reader . GetInt32 ( index ) ) ;
43- else if ( property . PropertyType == typeof ( bool ) )
46+ else if ( property . PropertyType == typeof ( bool ) )
4447 property . SetValue ( obj , reader . GetBoolean ( index ) ) ;
4548 else if ( property . PropertyType == typeof ( float ) )
4649 property . SetValue ( obj , reader . GetFloat ( index ) ) ;
4750 else
48- throw new NotImplementedException ( $ "Not implemented type : { property . PropertyType . Name } ") ;
51+ throw new NotImplementedException (
52+ $ "Not implemented type : { property . PropertyType . Name } "
53+ ) ;
4954 index ++ ;
5055 }
5156 Objects . Add ( obj ) ;
@@ -58,4 +63,4 @@ public SQLiteDataTable(string dbFile, string version = "3")
5863 {
5964 return Objects . Find ( predicate ) ;
6065 }
61- }
66+ }
0 commit comments