File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11namespace Belin . Sql . Reflection ;
22
3- using System . Collections . Concurrent ;
3+ using System . Collections . Frozen ;
44using System . ComponentModel . DataAnnotations . Schema ;
55using System . Reflection ;
66
@@ -39,17 +39,14 @@ public sealed class TableInfo {
3939 /// </summary>
4040 /// <param name="type">The type information providing the table metadata.</param>
4141 public TableInfo ( Type type ) {
42- var properties =
42+ var table = type . GetCustomAttribute < TableAttribute > ( ) ;
43+ var columns =
4344 from property in type . GetProperties ( BindingFlags . Instance | BindingFlags . NonPublic | BindingFlags . Public )
4445 where ! property . IsDefined ( typeof ( NotMappedAttribute ) ) && ( ( property . CanRead && property . CanWrite ) || property . IsDefined ( typeof ( ColumnAttribute ) ) )
45- select property ;
46-
47- var table = type . GetCustomAttribute < TableAttribute > ( ) ;
48- var columns = new ConcurrentDictionary < string , ColumnInfo > ( ) ;
49- foreach ( var property in properties ) columns . TryAdd ( property . Name , new ColumnInfo ( property ) ) ;
46+ select new ColumnInfo ( property ) ;
5047
51- Columns = columns ;
52- IdentityColumn = columns . Values . SingleOrDefault ( column => column . IsIdentity ) ?? ( columns . TryGetValue ( "Id" , out var column ) ? column : null ) ;
48+ Columns = columns . ToFrozenDictionary ( column => column . Name ) ;
49+ IdentityColumn = Columns . Values . SingleOrDefault ( column => column . IsIdentity ) ?? ( Columns . TryGetValue ( "Id" , out var column ) ? column : null ) ;
5350 Name = table ? . Name ?? type . Name ;
5451 Schema = table ? . Schema ;
5552 Type = type ;
Original file line number Diff line number Diff line change 1- [ assembly: Parallelize ( Scope = ExecutionScope . MethodLevel ) ]
1+ [ assembly: Parallelize ( Scope = ExecutionScope . ClassLevel ) ]
You can’t perform that action at this time.
0 commit comments